Skip to content

Environment activation changes custom scopes priority #48414

@alalazo

Description

@alalazo

Steps to reproduce

This is similar to #48254, and refers to #48255 (comment)

A simple reproducer is the following script:

# config_scopes.py
import spack.config
import spack.environment

print(f"BEFORE: {', '.join(spack.config.CONFIG.scopes)}\n")
with spack.environment.no_active_environment():
    print(f"NO ENV: {', '.join(spack.config.CONFIG.scopes)}\n")
print(f"AFTER: {', '.join(spack.config.CONFIG.scopes)}\n")

run with an environment active:

$ spack env activate --temp
==> Created and activated temporary environment in /tmp/spack-6mtybnl2
$ spack -C /tmp python config_scopes.py

Error message

There is no error message, but the output is wrong:

$ spack -C /tmp python ~/PycharmProjects/spack/config_scope.py
BEFORE: _builtin, defaults, defaults/linux, system, system/linux, site, site/linux, user, user/linux, env:/tmp/spack-j27fvyfw, cmd_scope_0, cmd_scope_0/linux, command_line

NO ENV: _builtin, defaults, defaults/linux, system, system/linux, site, site/linux, user, user/linux, cmd_scope_0, cmd_scope_0/linux, command_line

AFTER: _builtin, defaults, defaults/linux, system, system/linux, site, site/linux, user, user/linux, cmd_scope_0, cmd_scope_0/linux, env:/tmp/spack-j27fvyfw, command_line

When we exit the context manager, the environment has higher priority than the custom config scopes.

Information on your system

  • Spack: 0.24.0.dev0 (fc24be5)
  • Python: 3.13.0
  • Platform: linux-ubuntu20.04-icelake

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions