Skip to content

Commit

Permalink
Improve error message for forgetting to use source with activate and …
Browse files Browse the repository at this point in the history
…deactivate

Fixes conda#601.
  • Loading branch information
asmeurer committed Oct 1, 2014
1 parent 9c9b7f0 commit 7cdcae9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bin/activate
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Ensure that this script is sourced, not executed
# Note that if the script was executed, we're running inside bash!
if [[ -n $BASH_VERSION ]] && [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
>&2 echo "Error: activate must be sourced. Run 'source activate envname'
instead of 'activate envname'.
"
"$(dirname "$0")/conda" ..activate -h
exit 1
fi
Expand Down
3 changes: 3 additions & 0 deletions bin/deactivate
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Ensure that this script is sourced, not executed
# Note that if the script was executed, we're running inside bash!
if [[ -n $BASH_VERSION ]] && [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
>&2 echo "Error: deactivate must be sourced. Run 'source deactivate'
instead of 'deactivate'.
"
"$(dirname $0)/conda" ..deactivate -h
exit 1
fi
Expand Down
2 changes: 2 additions & 0 deletions tests/test_activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def test_activate_help():

stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert "activate must be sourced" in stderr
assert "Usage: source activate ENV" in stderr

commands = (command_setup + """
Expand All @@ -222,6 +223,7 @@ def test_activate_help():

stdout, stderr = run_in(commands, shell)
assert stdout == ''
assert "deactivate must be sourced" in stderr
assert "Usage: source deactivate" in stderr

commands = (command_setup + """
Expand Down

0 comments on commit 7cdcae9

Please sign in to comment.