From 7cdcae9414c11f00702f8718387c9c24779725e5 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Wed, 1 Oct 2014 18:06:10 -0500 Subject: [PATCH] Improve error message for forgetting to use source with activate and deactivate Fixes #601. --- bin/activate | 3 +++ bin/deactivate | 3 +++ tests/test_activate.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/bin/activate b/bin/activate index 2c16348f0f6..08d6d9aaba8 100755 --- a/bin/activate +++ b/bin/activate @@ -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 diff --git a/bin/deactivate b/bin/deactivate index a5cd12da3cf..c6e75d156b3 100755 --- a/bin/deactivate +++ b/bin/deactivate @@ -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 diff --git a/tests/test_activate.py b/tests/test_activate.py index fe5fd7946f0..7d840dfcd1f 100644 --- a/tests/test_activate.py +++ b/tests/test_activate.py @@ -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 + """ @@ -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 + """