summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/environment.py5
-rw-r--r--lib/spack/spack/test/cmd/env.py30
2 files changed, 33 insertions, 2 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index 00af2df2d9..1b9df358f4 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -37,6 +37,7 @@ from spack.spec import Spec
from spack.spec_list import SpecList, InvalidSpecConstraintError
from spack.variant import UnknownVariantError
import spack.util.lock as lk
+from spack.util.path import substitute_path_variables
#: environment variable used to indicate the active environment
spack_env_var = 'SPACK_ENV'
@@ -780,8 +781,8 @@ class Environment(object):
# highest-precedence scopes are last.
includes = config_dict(self.yaml).get('include', [])
for i, config_path in enumerate(reversed(includes)):
- # allow paths to contain environment variables
- config_path = config_path.format(**os.environ)
+ # allow paths to contain spack config/environment variables, etc.
+ config_path = substitute_path_variables(config_path)
# treat relative paths as relative to the environment
if not os.path.isabs(config_path):
diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py
index f8ed37e17c..5703738731 100644
--- a/lib/spack/spack/test/cmd/env.py
+++ b/lib/spack/spack/test/cmd/env.py
@@ -22,6 +22,7 @@ from spack.stage import stage_prefix
from spack.spec_list import SpecListError
from spack.util.mock_package import MockPackageMultiRepo
import spack.util.spack_json as sjson
+from spack.util.path import substitute_path_variables
# everything here uses the mock_env_path
@@ -539,6 +540,35 @@ packages:
for x in e._get_environment_specs())
+def test_env_with_included_config_var_path():
+ config_var_path = os.path.join('$tempdir', 'included-config.yaml')
+ test_config = """\
+env:
+ include:
+ - %s
+ specs:
+ - mpileaks
+""" % config_var_path
+
+ _env_create('test', StringIO(test_config))
+ e = ev.read('test')
+
+ config_real_path = substitute_path_variables(config_var_path)
+ fs.mkdirp(os.path.dirname(config_real_path))
+ with open(config_real_path, 'w') as f:
+ f.write("""\
+packages:
+ mpileaks:
+ version: [2.2]
+""")
+
+ with e:
+ e.concretize()
+
+ assert any(x.satisfies('mpileaks@2.2')
+ for x in e._get_environment_specs())
+
+
def test_env_config_precedence():
test_config = """\
env: