summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew W Elble <aweits@rit.edu>2021-12-16 05:54:35 -0500
committerGitHub <noreply@github.com>2021-12-16 10:54:35 +0000
commit96535cc4f994e0f2015a31dbe24c14a826b11145 (patch)
tree044f5866526be774391169fec78267a532a037fe /lib
parentbd0ffa8a3c969c219989e44d41bbd99df476282c (diff)
downloadspack-96535cc4f994e0f2015a31dbe24c14a826b11145.tar.gz
spack-96535cc4f994e0f2015a31dbe24c14a826b11145.tar.bz2
spack-96535cc4f994e0f2015a31dbe24c14a826b11145.tar.xz
spack-96535cc4f994e0f2015a31dbe24c14a826b11145.zip
MANPATH needs a trailing ':' to utilize system defaults (#21682)
otherwise spack breaks using system man pages by default. Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/cmd/load.py19
-rw-r--r--lib/spack/spack/util/environment.py4
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/spack/spack/test/cmd/load.py b/lib/spack/spack/test/cmd/load.py
index ef014418c7..51867b548c 100644
--- a/lib/spack/spack/test/cmd/load.py
+++ b/lib/spack/spack/test/cmd/load.py
@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+import re
import pytest
@@ -16,6 +17,24 @@ install = SpackCommand('install')
location = SpackCommand('location')
+def test_manpath_trailing_colon(install_mockery, mock_fetch, mock_archive,
+ mock_packages, working_env):
+ """Test that the commands generated by load add the MANPATH prefix
+ inspections. Also test that Spack correctly preserves the default/existing
+ manpath search path via a trailing colon"""
+ install('mpileaks')
+
+ sh_out = load('--sh', '--only', 'package', 'mpileaks')
+ lines = sh_out.split('\n')
+ assert any(re.match(r'export MANPATH=.*:;', ln) for ln in lines)
+
+ os.environ['MANPATH'] = '/tmp/man:'
+
+ sh_out = load('--sh', '--only', 'package', 'mpileaks')
+ lines = sh_out.split('\n')
+ assert any(re.match(r'export MANPATH=.*:/tmp/man:;', ln) for ln in lines)
+
+
def test_load(install_mockery, mock_fetch, mock_archive, mock_packages):
"""Test that the commands generated by load add the specified prefix
inspections. Also test that Spack records loaded specs by hash in the
diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py
index a0a6c4a3aa..f0457c27b8 100644
--- a/lib/spack/spack/util/environment.py
+++ b/lib/spack/spack/util/environment.py
@@ -611,7 +611,6 @@ class EnvironmentModifications(object):
def shell_modifications(self, shell='sh', explicit=False, env=None):
"""Return shell code to apply the modifications and clears the list."""
modifications = self.group_by_name()
- new_env = os.environ.copy()
if env is None:
env = os.environ
@@ -622,6 +621,9 @@ class EnvironmentModifications(object):
for x in actions:
x.execute(new_env)
+ if 'MANPATH' in new_env and not new_env.get('MANPATH').endswith(':'):
+ new_env['MANPATH'] += ':'
+
cmds = ''
for name in sorted(set(modifications)):