summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Melara <maamelara@gmail.com>2019-03-27 10:26:52 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2019-03-27 10:26:52 -0700
commit298a55b28fcc04e4085e14c6f2999e14cc224d60 (patch)
tree338209a5a1c38a121dc8ee3fd0df12a9c0f7ccdb
parent8a4e762bec15473b97f5502dbdf7a835f8ccf013 (diff)
downloadspack-298a55b28fcc04e4085e14c6f2999e14cc224d60.tar.gz
spack-298a55b28fcc04e4085e14c6f2999e14cc224d60.tar.bz2
spack-298a55b28fcc04e4085e14c6f2999e14cc224d60.tar.xz
spack-298a55b28fcc04e4085e14c6f2999e14cc224d60.zip
Replace previous bash command to new one (#7005)
Prevents infinite recursion caused by sourcing `setup-env.sh` in bashrc
-rw-r--r--lib/spack/spack/platforms/cray.py21
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/spack/spack/platforms/cray.py b/lib/spack/spack/platforms/cray.py
index 6e740cc703..ee3d40dc21 100644
--- a/lib/spack/spack/platforms/cray.py
+++ b/lib/spack/spack/platforms/cray.py
@@ -115,24 +115,13 @@ class Cray(Platform):
A bash subshell is launched with a wiped environment and the list of
loaded modules is parsed for the first acceptable CrayPE target.
'''
- # Based on the incantation:
- # echo "$(env - USER=$USER /bin/bash -l -c 'module list -lt')"
+ # env -i /bin/bash -lc echo $CRAY_CPU_TARGET 2> /dev/null
if getattr(self, 'default', None) is None:
env = which('env')
- env.add_default_arg('-')
- # CAUTION - $USER is generally needed in the sub-environment.
- # There may be other variables needed for general success.
- output = env('USER=%s' % os.environ['USER'],
- 'HOME=%s' % os.environ['HOME'],
- '/bin/bash', '--noprofile', '--norc', '-c',
- '. /etc/profile; module list -lt',
- output=str, error=str)
- self._defmods = _get_modules_in_modulecmd_output(output)
- targets = []
- _fill_craype_targets_from_modules(targets, self._defmods)
- self.default = targets[0] if targets else None
- tty.debug("Found default modules:",
- *[" %s" % mod for mod in self._defmods])
+ output = env("-i", "/bin/bash", "-lc", "echo $CRAY_CPU_TARGET",
+ output=str, error=os.devnull)
+ self.default = output.strip()
+ tty.debug("Found default module:%s" % self.default)
return self.default
def _avail_targets(self):