diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index 04880d073f..9b9f8c7d17 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -829,8 +829,7 @@ def included_config_scopes(self): scope = spack.config.ConfigScope(config_name, config_path) elif os.path.exists(config_path): # files are assumed to be SingleFileScopes - base, ext = os.path.splitext(os.path.basename(config_path)) - config_name = 'env:%s:%s' % (self.name, base) + config_name = 'env:%s:%s' % (self.name, config_path) scope = spack.config.SingleFileScope( config_name, config_path, spack.schema.merged.schema) else: diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index a1c7e8bf01..998dd5d876 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -547,6 +547,48 @@ def test_with_config_bad_include(env_deactivate, capfd): assert 'no/such/file.yaml' in err +def test_env_with_include_config_files_same_basename(): + test_config = """\ + env: + include: + - ./path/to/included-config.yaml + - ./second/path/to/include-config.yaml + specs: + [libelf, mpileaks] + """ + + _env_create('test', StringIO(test_config)) + e = ev.read('test') + + fs.mkdirp(os.path.join(e.path, 'path', 'to')) + with open(os.path.join( + e.path, + './path/to/included-config.yaml'), 'w') as f: + f.write("""\ + packages: + libelf: + version: [0.8.10] + """) + + fs.mkdirp(os.path.join(e.path, 'second', 'path', 'to')) + with open(os.path.join( + e.path, + './second/path/to/include-config.yaml'), 'w') as f: + f.write("""\ + packages: + mpileaks: + version: [2.2] + """) + + with e: + e.concretize() + + environment_specs = e._get_environment_specs(False) + + assert(environment_specs[0].satisfies('libelf@0.8.10')) + assert(environment_specs[1].satisfies('mpileaks@2.2')) + + def test_env_with_included_config_file(): test_config = """\ env: