Skip to content
Snippets Groups Projects
Commit 298a55b2 authored by Mario Melara's avatar Mario Melara Committed by Todd Gamblin
Browse files

Replace previous bash command to new one (#7005)

Prevents infinite recursion caused by sourcing `setup-env.sh` in bashrc
parent 8a4e762b
No related branches found
No related tags found
No related merge requests found
...@@ -115,24 +115,13 @@ def _default_target_from_env(self): ...@@ -115,24 +115,13 @@ def _default_target_from_env(self):
A bash subshell is launched with a wiped environment and the list of A bash subshell is launched with a wiped environment and the list of
loaded modules is parsed for the first acceptable CrayPE target. loaded modules is parsed for the first acceptable CrayPE target.
''' '''
# Based on the incantation: # env -i /bin/bash -lc echo $CRAY_CPU_TARGET 2> /dev/null
# echo "$(env - USER=$USER /bin/bash -l -c 'module list -lt')"
if getattr(self, 'default', None) is None: if getattr(self, 'default', None) is None:
env = which('env') env = which('env')
env.add_default_arg('-') output = env("-i", "/bin/bash", "-lc", "echo $CRAY_CPU_TARGET",
# CAUTION - $USER is generally needed in the sub-environment. output=str, error=os.devnull)
# There may be other variables needed for general success. self.default = output.strip()
output = env('USER=%s' % os.environ['USER'], tty.debug("Found default module:%s" % self.default)
'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])
return self.default return self.default
def _avail_targets(self): def _avail_targets(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment