diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py index 1666f4711e3609..6eab6d316e50e2 100644 --- a/lib/spack/spack/util/environment.py +++ b/lib/spack/spack/util/environment.py @@ -446,7 +446,12 @@ def from_sourcing_file(filename, *args, **kwargs): for k, v in env_after.items()) # Other variables unrelated to sourcing a file - blacklist.extend(['SHLVL', '_', 'PWD', 'OLDPWD', 'PS2']) + blacklist.extend([ + # Bash internals + 'SHLVL', '_', 'PWD', 'OLDPWD', 'PS2', 'ENV', + # Environment modules v4 + 'LOADEDMODULES', '_LMFILES_', 'BASH_FUNC_module()' + ]) def set_intersection(fullset, *args): # A set intersection using string literals and regexs