Skip to content

Commit 5ddebeb

Browse files
authored
Fix: update install_rmg.sh to conditionally apply strict channel priority flag (#825)
This PR improves compatibility in the `devtools/install_rmg.sh` script when managing environments with different package managers. The main change is to ensure that the `--strict-channel-priority` flag is only used with `mamba` or `micromamba`, as it is not supported by `conda`.
2 parents 453c8e2 + 36b1b23 commit 5ddebeb

1 file changed

Lines changed: 52 additions & 19 deletions

File tree

devtools/install_rmg.sh

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,18 @@ if [[ "$MODE" == "source" ]]; then
127127
exit 1
128128
fi
129129

130+
# Prepare flags - --strict-channel-priority only works with mamba/micromamba on create
131+
CHANNEL_PRIORITY_FLAG=""
132+
if [[ "$COMMAND_PKG" != "conda" ]]; then
133+
CHANNEL_PRIORITY_FLAG="--strict-channel-priority"
134+
fi
135+
130136
if $COMMAND_PKG env list | awk '{print $1}' | grep -qx "$ENV_NAME"; then
131137
echo ">>> Updating existing environment: $ENV_NAME"
132-
$COMMAND_PKG env update -n "$ENV_NAME" -f environment.yml --prune --strict-channel-priority
138+
$COMMAND_PKG env update -n "$ENV_NAME" -f environment.yml --prune -y
133139
else
134-
echo ">>> Creating new environment: $ENV_NAME"
135-
$COMMAND_PKG env create -n "$ENV_NAME" -f environment.yml -y --strict-channel-priority
140+
echo ">>> Creating new environment: $ENV_NAME"
141+
$COMMAND_PKG env create -n "$ENV_NAME" -f environment.yml -y $CHANNEL_PRIORITY_FLAG
136142
fi
137143

138144
###############################################################################
@@ -256,27 +262,46 @@ if [ "$INSTALL_RMS" = true ]; then
256262
# Check if juliaup is installed - juliaup &> /dev/null
257263
if ! command -v juliaup &> /dev/null; then
258264
echo " juliaup not found. Installing it now."
259-
curl -fsSL https://install.julialang.org | bash
265+
if ! curl -fsSL https://install.julialang.org | bash 2>/dev/null; then
266+
echo "❌ Failed to install juliaup. Skipping RMS installation."
267+
echo "ℹ️ You can manually install Julia 1.10+ and try again."
268+
exit 1
269+
fi
260270
export PATH="$HOME/.juliaup/bin:$PATH"
261271
# Add it to bashrc/zshrc
262272
echo 'export PATH="$HOME/.juliaup/bin:$PATH"' >> "$RC"
263273
# juliaup 1.10
264-
juliaup add 1.10
265-
juliaup default 1.10
266-
juliaup remove release
274+
if ! juliaup add 1.10 2>/dev/null || ! juliaup default 1.10 2>/dev/null; then
275+
echo "❌ Failed to configure Julia 1.10. Skipping RMS installation."
276+
exit 1
277+
fi
278+
juliaup remove release 2>/dev/null || true
267279
else
268280
echo "✔️ juliaup is already installed."
281+
export PATH="$HOME/.juliaup/bin:$PATH"
282+
269283
echo "Checking for Julia 1.10..."
270-
if ! julia --version | grep -q "1\.10"; then
271-
echo "❌ Julia 1.10 not found. Installing it now."
272-
juliaup add 1.10
273-
juliaup default 1.10
284+
if ! "$HOME/.juliaup/bin/julialauncher" --version 2>/dev/null | grep -q "1\.10"; then
285+
echo " Julia 1.10 not found. Installing it now..."
286+
"$HOME/.juliaup/bin/juliaup" add 1.10
287+
"$HOME/.juliaup/bin/juliaup" default 1.10
288+
# Verify installation
289+
if ! "$HOME/.juliaup/bin/julialauncher" --version 2>/dev/null | grep -q "1\.10"; then
290+
echo "❌ Failed to install Julia 1.10. Skipping RMS installation."
291+
exit 1
292+
fi
293+
echo "✔️ Julia 1.10 installed successfully."
274294
else
275295
echo "✔️ Julia 1.10 is already installed."
276296
fi
277-
# Get julia path
278-
JULIA_PATH=$(which julia)
279-
echo "Using Julia at: $JULIA_PATH"
297+
# Get julia path via julialauncher - already set to 1.10 as default
298+
JULIA_PATH="$HOME/.juliaup/bin/julialauncher"
299+
if [[ ! -f "$JULIA_PATH" ]]; then
300+
echo "❌ Julia launcher not found at $JULIA_PATH. Skipping RMS installation."
301+
exit 1
302+
fi
303+
304+
echo "Using Julia launcher: $JULIA_PATH (1.10 is default)"
280305
# Set the micromamba/conda/mamba env config vars
281306
# Find the base path - check COMMAND_PKG is micromamba, mamba, or conda
282307
if [ "$COMMAND_PKG" = "micromamba" ]; then
@@ -293,14 +318,14 @@ if [ "$INSTALL_RMS" = true ]; then
293318
conda env config vars set -n "$ENV_NAME" \
294319
JULIA_CONDAPKG_BACKEND=Null \
295320
JULIA_PYTHONCALL_EXE=$BASE_PATH/envs/$ENV_NAME/bin/python \
296-
PYTHON_JULIAPKG_EXE=$JULIA_PATH \
321+
PYTHON_JULIAPKG_EXE="$JULIA_PATH" \
297322
PYTHON_JULIAPKG_PROJECT=$BASE_PATH/envs/$ENV_NAME/julia_env
298323
else
299324
mkdir -p "$BASE_PATH/envs/$ENV_NAME/etc/conda/activate.d"
300325
cat > "$BASE_PATH/envs/$ENV_NAME/etc/conda/activate.d/julia_vars.sh" <<'EOF'
301326
export JULIA_CONDAPKG_BACKEND=Null
302327
export JULIA_PYTHONCALL_EXE="$CONDA_PREFIX/bin/python"
303-
export PYTHON_JULIAPKG_EXE="$(command -v julia)"
328+
export PYTHON_JULIAPKG_EXE="$HOME/.juliaup/bin/julialauncher"
304329
export PYTHON_JULIAPKG_PROJECT="$CONDA_PREFIX/julia_env"
305330
EOF
306331

@@ -309,15 +334,23 @@ EOF
309334
# Now export the variables to the current shell
310335
export JULIA_CONDAPKG_BACKEND=Null
311336
export JULIA_PYTHONCALL_EXE=$BASE_PATH/envs/$ENV_NAME/bin/python
312-
export PYTHON_JULIAPKG_EXE=$JULIA_PATH
337+
export PYTHON_JULIAPKG_EXE="$JULIA_PATH"
313338
export PYTHON_JULIAPKG_PROJECT=$BASE_PATH/envs/$ENV_NAME/julia_env
314339

315340
# install pyjuliacall
316341
echo "📦 Installing PyJuliaCall in $ENV_NAME"
317342
$COMMAND_PKG install -n "$ENV_NAME" -c conda-forge pyjuliacall -y
343+
344+
# Ensure Julia uses conda's libstdc++
345+
echo "🔧 Configuring Julia to use conda's libstdc++..."
346+
JDIR="$("$JULIA_PATH" -e 'println(joinpath(Sys.BINDIR,"..","lib","julia"))')"
347+
[ -f "$JDIR/libstdc++.so.6.bak" ] || mv "$JDIR/libstdc++.so.6" "$JDIR/libstdc++.so.6.bak" 2>/dev/null || true
348+
ln -sf "$BASE_PATH/envs/$ENV_NAME/lib/libstdc++.so.6" "$JDIR/libstdc++.so.6" || \
349+
cp -L "$BASE_PATH/envs/$ENV_NAME/lib/libstdc++.so.6" "$JDIR/libstdc++.so.6"
350+
318351
export RMS_BRANCH=${RMS_BRANCH:-for_rmg}
319352
echo "📦 Installing ReactionMechanismSimulator - BRANCH: $RMS_BRANCH"
320-
$COMMAND_PKG run -n "$ENV_NAME" julia -e '
353+
"$JULIA_PATH" -e '
321354
using Pkg;
322355
Pkg.add(Pkg.PackageSpec(
323356
name="ReactionMechanismSimulator",
@@ -326,7 +359,7 @@ EOF
326359
));
327360
using ReactionMechanismSimulator;
328361
Pkg.instantiate();
329-
' || echo "RMS install error – continuing anyway ¯\_(ツ)_/¯" # conda-run executes in env
362+
'
330363
echo "Checking if RMS is installed..."
331364
ENV_NAME="$ENV_NAME" $COMMAND_PKG run -n "$ENV_NAME" python - <<'PY'
332365
from juliacall import Main

0 commit comments

Comments
 (0)