diff --git a/lib/spack/spack/test/module_parsing.py b/lib/spack/spack/test/module_parsing.py index 63eafcca26b..7483b66ebb1 100644 --- a/lib/spack/spack/test/module_parsing.py +++ b/lib/spack/spack/test/module_parsing.py @@ -53,7 +53,8 @@ def test_get_path_from_module(save_env): lines = ['prepend-path LD_LIBRARY_PATH /path/to/lib', 'setenv MOD_DIR /path/to', 'setenv LDFLAGS -Wl,-rpath/path/to/lib', - 'setenv LDFLAGS -L/path/to/lib'] + 'setenv LDFLAGS -L/path/to/lib', + 'prepend-path PATH /path/to/bin'] for line in lines: module_func = '() { eval `echo ' + line + ' bash filler`\n}' diff --git a/lib/spack/spack/util/module_cmd.py b/lib/spack/spack/util/module_cmd.py index c2448aa2782..a726023d957 100644 --- a/lib/spack/spack/util/module_cmd.py +++ b/lib/spack/spack/util/module_cmd.py @@ -187,6 +187,12 @@ def get_path_from_module(mod): if L >= 0: return line[L + 2:line.find('/lib')] + # If it sets the PATH, use it + for line in text: + if line.find('PATH') >= 0: + path = get_argument_from_module_line(line) + return path[:path.find('/bin')] + # Unable to find module path return None