More robust env.sh | Fix conda activate if in subshell
This commit is contained in:
@@ -250,11 +250,25 @@ if run_step "10"; then
|
||||
exit_if_last_command_failed
|
||||
fi
|
||||
|
||||
cat <<EOT >> env.sh
|
||||
# line auto-generated by $0
|
||||
# Conda Setup
|
||||
# Provide a sourceable snippet that can be used in subshells that may not have
|
||||
# inhereted conda functions that would be brought in under a login shell that
|
||||
# has run conda init (e.g., VSCode, CI)
|
||||
read -r -d '\0' CONDA_ACTIVATE_PREAMBLE <<'END_CONDA_ACTIVATE'
|
||||
if ! type conda >& /dev/null; then
|
||||
echo "::ERROR:: you must have conda in your environment first"
|
||||
return 1 # don't want to exit here because this file is sourced
|
||||
fi
|
||||
|
||||
# if we're sourcing this in a sub process that has conda in the PATH but not as a function, init it again
|
||||
conda activate --help >& /dev/null || source $(conda info --base)/etc/profile.d/conda.sh
|
||||
\0
|
||||
END_CONDA_ACTIVATE
|
||||
|
||||
replace_content env.sh build-setup "# line auto-generated by $0
|
||||
$CONDA_ACTIVATE_PREAMBLE
|
||||
conda activate $CYDIR/.conda-env
|
||||
source $CYDIR/scripts/fix-open-files.sh
|
||||
EOT
|
||||
source $CYDIR/scripts/fix-open-files.sh"
|
||||
|
||||
echo "Setup complete!"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user