Skip to content

Commit 4e3ccd7

Browse files
Copilotabdurriq
andauthored
Fix conda installation failure due to SHA1 signature rejection (#1565)
* Initial plan * Fix conda installation by switching from apt repository to direct Miniconda installer Co-authored-by: abdurriq <[email protected]> * Add error handling for Miniconda download and installation Co-authored-by: abdurriq <[email protected]> * Use APT::Key::GPGVCommand=1 option to bypass SHA1 signature check Co-authored-by: abdurriq <[email protected]> * Fix version to 1.2.1 for semantic versioning * Revert to Miniconda installer approach - APT option caused gpgv errors Co-authored-by: abdurriq <[email protected]> * Use mktemp for secure temporary file creation Co-authored-by: abdurriq <[email protected]> * Replace Miniconda installer with direct .deb package download and apt install Co-authored-by: abdurriq <[email protected]> * Fix apt-get install syntax and improve error handling Co-authored-by: abdurriq <[email protected]> * Fix package filename - use architecture-specific deb and extract Filename from Packages Co-authored-by: abdurriq <[email protected]> * Update version to 1.2.3 Co-authored-by: abdurriq <[email protected]> * Fix apt-get install path - remove ./ prefix for absolute paths Co-authored-by: abdurriq <[email protected]> * Fix version matching for specific conda versions - handle version suffixes Co-authored-by: abdurriq <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: abdurriq <[email protected]>
1 parent c2f0fbf commit 4e3ccd7

2 files changed

Lines changed: 107 additions & 49 deletions

File tree

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
{
2-
"id": "conda",
3-
"version": "1.1.0",
4-
"name": "Conda",
5-
"description": "A cross-platform, language-agnostic binary package manager",
6-
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/conda",
7-
"options": {
8-
"version": {
9-
"type": "string",
10-
"proposals": [
11-
"latest",
12-
"4.11.0",
13-
"4.12.0"
14-
],
15-
"default": "latest",
16-
"description": "Select or enter a conda version."
17-
},
18-
"addCondaForge": {
19-
"type": "boolean",
20-
"default": false,
21-
"description": "Add conda-forge channel to the config?"
22-
}
2+
"id": "conda",
3+
"version": "1.2.5",
4+
"name": "Conda",
5+
"description": "A cross-platform, language-agnostic binary package manager",
6+
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/conda",
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"proposals": [
11+
"latest",
12+
"4.11.0",
13+
"4.12.0"
14+
],
15+
"default": "latest",
16+
"description": "Select or enter a conda version."
2317
},
24-
"containerEnv": {
25-
"CONDA_DIR": "/opt/conda",
26-
"CONDA_SCRIPT": "/opt/conda/etc/profile.d/conda.sh",
27-
"PATH": "/opt/conda/bin:${PATH}"
28-
},
29-
"customizations": {
30-
"vscode": {
31-
"settings": {
32-
"github.copilot.chat.codeGeneration.instructions": [
33-
{
34-
"text": "This dev container includes the conda package manager pre-installed and available on the `PATH` for data science and Python development. Additional packages installed using Conda will be downloaded from Anaconda or another repository configured by the user. A user can install different versions of Python than the one in this dev container by running a command like: conda install python=3.7"
35-
}
36-
]
37-
}
38-
}
39-
},
40-
"installsAfter": [
41-
"ghcr.io/devcontainers/features/common-utils"
42-
]
18+
"addCondaForge": {
19+
"type": "boolean",
20+
"default": false,
21+
"description": "Add conda-forge channel to the config?"
22+
}
23+
},
24+
"containerEnv": {
25+
"CONDA_DIR": "/opt/conda",
26+
"CONDA_SCRIPT": "/opt/conda/etc/profile.d/conda.sh",
27+
"PATH": "/opt/conda/bin:${PATH}"
28+
},
29+
"customizations": {
30+
"vscode": {
31+
"settings": {
32+
"github.copilot.chat.codeGeneration.instructions": [
33+
{
34+
"text": "This dev container includes the conda package manager pre-installed and available on the `PATH` for data science and Python development. Additional packages installed using Conda will be downloaded from Anaconda or another repository configured by the user. A user can install different versions of Python than the one in this dev container by running a command like: conda install python=3.7"
35+
}
36+
]
37+
}
38+
}
39+
},
40+
"installsAfter": [
41+
"ghcr.io/devcontainers/features/common-utils"
42+
]
4343
}

src/conda/install.sh

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,78 @@ if ! conda --version &> /dev/null ; then
7373
usermod -a -G conda "${USERNAME}"
7474

7575
# Install dependencies
76-
check_packages curl ca-certificates gnupg2
76+
check_packages curl ca-certificates
7777

7878
echo "Installing Conda..."
7979

80-
curl -sS https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > /usr/share/keyrings/conda-archive-keyring.gpg
81-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list
82-
apt-get update -y
83-
84-
CONDA_PKG="conda=${VERSION}-0"
80+
# Download .deb package directly from repository (bypassing SHA1 signature issue)
81+
TEMP_DEB="$(mktemp -t conda_XXXXXX.deb)"
82+
CONDA_REPO_BASE="https://repo.anaconda.com/pkgs/misc/debrepo/conda"
83+
84+
# Determine package filename based on requested version
85+
ARCH="$(dpkg --print-architecture 2>/dev/null || echo "amd64")"
86+
PACKAGES_URL="https://repo.anaconda.com/pkgs/misc/debrepo/conda/dists/stable/main/binary-${ARCH}/Packages"
87+
8588
if [ "${VERSION}" = "latest" ]; then
86-
CONDA_PKG="conda"
89+
# For latest, we need to query the repository to find the current version
90+
echo "Fetching package list to determine latest version..."
91+
CONDA_PKG_INFO=$(curl -fsSL "${PACKAGES_URL}" | grep -A 30 "^Package: conda$" | head -n 31)
92+
CONDA_VERSION=$(echo "${CONDA_PKG_INFO}" | grep "^Version:" | head -n 1 | awk '{print $2}')
93+
CONDA_FILENAME=$(echo "${CONDA_PKG_INFO}" | grep "^Filename:" | head -n 1 | awk '{print $2}')
94+
95+
if [ -z "${CONDA_VERSION}" ] || [ -z "${CONDA_FILENAME}" ]; then
96+
echo "ERROR: Could not determine latest conda version or filename from ${PACKAGES_URL}"
97+
echo "This may indicate an unsupported architecture or repository unavailability."
98+
rm -f "${TEMP_DEB}"
99+
exit 1
100+
fi
101+
102+
CONDA_PKG_NAME="${CONDA_FILENAME}"
103+
else
104+
# For specific versions, query the Packages file to find the exact filename
105+
echo "Fetching package list to find version ${VERSION}..."
106+
# Search for version pattern - user may specify 4.12.0 but package has 4.12.0-0
107+
CONDA_PKG_INFO=$(curl -fsSL "${PACKAGES_URL}" | grep -A 30 "^Package: conda$" | grep -B 5 -A 25 "^Version: ${VERSION}")
108+
CONDA_FILENAME=$(echo "${CONDA_PKG_INFO}" | grep "^Filename:" | head -n 1 | awk '{print $2}')
109+
110+
if [ -z "${CONDA_FILENAME}" ]; then
111+
echo "ERROR: Could not find conda version ${VERSION} in ${PACKAGES_URL}"
112+
echo "Please verify the version specified is valid."
113+
rm -f "${TEMP_DEB}"
114+
exit 1
115+
fi
116+
117+
CONDA_PKG_NAME="${CONDA_FILENAME}"
87118
fi
88-
89-
check_packages $CONDA_PKG
119+
120+
# Download the .deb package
121+
CONDA_DEB_URL="${CONDA_REPO_BASE}/${CONDA_PKG_NAME}"
122+
echo "Downloading conda package from ${CONDA_DEB_URL}..."
123+
124+
if ! curl -fsSL "${CONDA_DEB_URL}" -o "${TEMP_DEB}"; then
125+
echo "ERROR: Failed to download conda .deb package from ${CONDA_DEB_URL}"
126+
echo "Please verify the version specified is valid."
127+
rm -f "${TEMP_DEB}"
128+
exit 1
129+
fi
130+
131+
# Verify the package was downloaded successfully
132+
if [ ! -f "${TEMP_DEB}" ] || [ ! -s "${TEMP_DEB}" ]; then
133+
echo "ERROR: Conda .deb package file is missing or empty"
134+
rm -f "${TEMP_DEB}"
135+
exit 1
136+
fi
137+
138+
# Install the package using apt (which handles dependencies automatically)
139+
echo "Installing conda package..."
140+
if ! apt-get install -y "${TEMP_DEB}"; then
141+
echo "ERROR: Failed to install conda package"
142+
rm -f "${TEMP_DEB}"
143+
exit 1
144+
fi
145+
146+
# Clean up downloaded package
147+
rm -f "${TEMP_DEB}"
90148

91149
CONDA_SCRIPT="/opt/conda/etc/profile.d/conda.sh"
92150
. $CONDA_SCRIPT

0 commit comments

Comments
 (0)