Skip to content

Commit

Permalink
Merge pull request #1409 from manics/terminal-no-set-e
Browse files Browse the repository at this point in the history
`set -e` should not be set after conda environment is sourced
  • Loading branch information
yuvipanda authored Feb 12, 2025
2 parents 374b8e5 + 12fc6dd commit b0cfd45
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion repo2docker/buildpacks/conda/activate-conda.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# enable conda and activate the notebook environment
set -ex
set -e
eval $(micromamba shell hook -s posix -r ${CONDA_DIR})
for name in conda mamba; do
CONDA_PROFILE="${CONDA_DIR}/etc/profile.d/${name}.sh"
Expand All @@ -21,3 +21,5 @@ if [[ "${KERNEL_PYTHON_PREFIX}" != "${NB_PYTHON_PREFIX}" ]]; then
else
mamba activate ${NB_PYTHON_PREFIX}
fi

set +e
2 changes: 2 additions & 0 deletions tests/venv/start/postBuild/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ postBuild and start

This test checks that we can use a postBuild and start script
at the same time.

It also checks that exit on error (set -e) has not leaked into the main shell.
7 changes: 6 additions & 1 deletion tests/venv/start/postBuild/verify
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
#!/bin/bash -il
# Run this as an interactive login shell so that the conda profile is sourced

# Test that `set -e` isn't incorrectly set in a profile
false

set -euo pipefail
grep 'Done!' $HOME/postbuild.txt
# set value of TEST_START_VAR to empty string when it is not defined
Expand Down

0 comments on commit b0cfd45

Please sign in to comment.