From 56b4abbe38379b7fe2c832b169e0117d76c21c6c Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Fri, 26 Jun 2020 17:20:15 -0500 Subject: env: no automatic activation (#17258) * env: no automatic activation * Ensure ci rebuild jobs activate the environment (no longer automagic) Co-authored-by: Scott Wittenburg --- lib/spack/docs/environments.rst | 9 --------- lib/spack/docs/pipelines.rst | 2 ++ lib/spack/spack/ci.py | 5 ++++- lib/spack/spack/environment.py | 13 ++++--------- 4 files changed, 10 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/spack/docs/environments.rst b/lib/spack/docs/environments.rst index cec7224a86..55ac458a3c 100644 --- a/lib/spack/docs/environments.rst +++ b/lib/spack/docs/environments.rst @@ -167,15 +167,6 @@ Any directory can be treated as an environment if it contains a file $ spack env activate -d /path/to/directory -Spack commands that are environment sensitive will also act on the -environment any time the current working directory contains a -``spack.yaml`` file. Changing working directory to a directory -containing a ``spack.yaml`` file is equivalent to the command: - -.. code-block:: console - - $ spack env activate -d /path/to/dir --without-view - Anonymous specs can be created in place using the command: .. code-block:: console diff --git a/lib/spack/docs/pipelines.rst b/lib/spack/docs/pipelines.rst index ee3b4e8ad6..34ff9cfc6d 100644 --- a/lib/spack/docs/pipelines.rst +++ b/lib/spack/docs/pipelines.rst @@ -45,6 +45,7 @@ for setting up a build pipeline are as follows: tags: - script: + - spack env activate . - spack ci generate --output-file "${CI_PROJECT_DIR}/jobs_scratch_dir/pipeline.yml" artifacts: @@ -384,6 +385,7 @@ a custom spack and make sure the generated rebuild jobs will clone it too: - git clone ${SPACK_REPO} --branch ${SPACK_REF} - . ./spack/share/spack/setup-env.sh script: + - spack env activate . - spack ci generate --spack-repo ${SPACK_REPO} --spack-ref ${SPACK_REF} --output-file "${CI_PROJECT_DIR}/jobs_scratch_dir/pipeline.yml" diff --git a/lib/spack/spack/ci.py b/lib/spack/spack/ci.py index abd5ca4b60..55d311d6a5 100644 --- a/lib/spack/spack/ci.py +++ b/lib/spack/spack/ci.py @@ -612,7 +612,10 @@ def generate_gitlab_ci_yaml(env, print_summary, output_file, if 'enable-debug-messages' in gitlab_ci: debug_flag = '-d ' - job_scripts = ['spack {0}ci rebuild'.format(debug_flag)] + job_scripts = [ + 'spack env activate .', + 'spack {0}ci rebuild'.format(debug_flag), + ] compiler_action = 'NONE' if len(phases) > 1: diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index 5ec683f6b2..32bd8c962d 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -247,18 +247,13 @@ def find_environment(args): # at env_dir (env and env_dir are mutually exclusive) env = getattr(args, 'env_dir', None) - # if no argument, look for a manifest file + # if no argument, look for the environment variable if not env: - if os.path.exists(manifest_name): - env = os.getcwd() + env = os.environ.get(spack_env_var) - # if no env, env_dir, or manifest try the environment + # nothing was set; there's no active environment if not env: - env = os.environ.get(spack_env_var) - - # nothing was set; there's no active environment - if not env: - return None + return None # if we get here, env isn't the name of a spack environment; it has # to be a path to an environment, or there is something wrong. -- cgit v1.2.3-60-g2f50