Skip to content

Commit

Permalink
[miniforge] no fail on existing installation (#167)
Browse files Browse the repository at this point in the history
Fixes #166 

Note that this does not handle the case where the existing version is
not the version requested. I started to address it, but it is made more
complicated by the fact that mambaforge versions don't seem to keep up
with official conda releases, so I didn't venture further down that path
(i.e. if someone comes with an image with a fresh conda install, we
would almost certainly be down-grading it here, which might not be
desired).

I also updated the devcontainer spec of this repo because it was using
an outdated `docker-from-docker` feature, which in turn made the tests
in the tests break when running in the devcontainer.
  • Loading branch information
rokroskar committed Jul 31, 2023
1 parent 5482996 commit 1e2af2d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"features": {
"ghcr.io/devcontainers/features/docker-from-docker:1": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest"
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/miniforge/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Conda, Mamba (Miniforge)",
"id": "miniforge",
"version": "1.0.0",
"version": "1.0.1",
"description": "Installs Conda and Mamba package manager and Python3. conda-forge set as the default (and only) channel.",
"documentationURL": "https://github.com/rocker-org/devcontainer-features/tree/main/src/miniforge",
"options": {
Expand Down
8 changes: 4 additions & 4 deletions src/miniforge/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ set -e
rm -rf /var/lib/apt/lists/*

if conda --version &>/dev/null; then
echo "(!) conda is already installed."
exit 1
echo "(!) conda is already installed - exiting."
exit 0
fi

if mamba --version &>/dev/null; then
echo "(!) mamba is already installed."
exit 1
echo "(!) mamba is already installed - exiting."
exit 0
fi

if [ "$(id -u)" -ne 0 ]; then
Expand Down
12 changes: 12 additions & 0 deletions test/miniforge/mambaforge-existing-conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

# shellcheck source=/dev/null
source dev-container-features-test-lib

# Check that conda is installed
check "conda" conda --version

# Report result
reportResults
7 changes: 7 additions & 0 deletions test/miniforge/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@
"variant": "Mambaforge-pypy3"
}
}
},
"mambaforge-existing-conda": {
"image": "jupyter/base-notebook",
"features":{
"miniforge": {}
},
"containerUser": "root"
}
}

0 comments on commit 1e2af2d

Please sign in to comment.