Skip to content
Snippets Groups Projects
Commit 7d8a4554 authored by Marty Kandes's avatar Marty Kandes
Browse files

FIX: Prepend Singularity install dir to PATH prior to final check

This bug fix prepends the path of the Singularity installation directory
to the PATH environment variable immediately following installation
using the naked-singularity.sh install command and the final check to
determine if Singularity was installed successfully. The problem here is
that not all secure_path in /etc/sudoers may include the Singualrity
install directory by default, which can lead this final install test to
fail erroneously.

This issue was observed when recently testing the naked-singularity.sh
install command on CentOS 7 and CentOS 8. Both install processes threw a
'Singularity installation failed!' error even though the installations
were successful [1] [2]. No such issue was observed on Ubuntu-based
installations [3]. As stated above, the difference in behavior between
these OSes was tracked down to what default paths were included in the
secure_path variable in the /etc/sudoers file [4] [5] [6].

[1]

...
 INSTALL CNI PLUGIN /usr/local/libexec/singularity/cni/tuning
 INSTALL CNI CONFIGURATION FILES
 DONE
make: Leaving directory `/tmp/singularity/builddir'
Checking if Singularity was installed successully ...
./naked-singularity.sh: line 200: singularity: command not found
ERROR :: Singularity installation failed!
ERROR :: Failed to run install command.
[centos@singularity-centos7-builder naked-singularity]$ singularity --version
singularity version 3.5.3
[centos@singularity-centos7-builder naked-singularity]$ which singularity
/usr/local/bin/singularity
[centos@singularity-centos7-builder naked-singularity]$

[2]

...
INSTALL CNI PLUGIN /usr/local/libexec/singularity/cni/tuning
 INSTALL CNI CONFIGURATION FILES
 DONE
make: Leaving directory '/tmp/singularity/builddir'
Checking if Singularity was installed successully ...
./naked-singularity.sh: line 200: singularity: command not found
ERROR :: Singularity installation failed!
ERROR :: Failed to run install command.
[centos@singularity-centos8-builder naked-singularity]$ singularity --version
singularity version 3.5.3
[centos@singularity-centos8-builder naked-singularity]$ which singularity
/usr/local/bin/singularity
[centos@singularity-centos8-builder naked-singularity]$

[3]

...
 INSTALL CNI PLUGIN /usr/local/libexec/singularity/cni/tuning
 INSTALL CNI CONFIGURATION FILES
 DONE
make: Leaving directory '/tmp/singularity/builddir'
Checking if Singularity was installed successully ...
singularity version 3.5.3
Singularity was installed successfully!
ubuntu@singularity-ubuntu1804-builder:~/naked-singularity$ singularity --versionsingularity version 3.5.3
ubuntu@singularity-ubuntu1804-builder:~/naked-singularity$ which singularity
/usr/local/bin/singularity
ubuntu@singularity-ubuntu1804-builder:~/naked-singularity$

[4]

[centos@singularity-centos7-builder naked-singularity]$ sudo cat /etc/sudoers | grep secure_path
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
[centos@singularity-centos7-builder naked-singularity]$

[5]

[centos@singularity-centos8-builder naked-singularity]$ sudo cat /etc/sudoers | grep secure_path
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
[centos@singularity-centos8-builder naked-singularity]$

[6]

ubuntu@singularity-ubuntu1804-builder:~/naked-singularity$ sudo cat /etc/sudoers | grep secure_path
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
ubuntu@singularity-ubuntu1804-builder:~/naked-singularity$
parent d57f2540
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,8 @@ University of California, San Diego
## Version
1.7.5
1.7.6
## Last Updated
Thursday, July 22nd, 2021
Friday, July 23rd, 2021
......@@ -17,7 +17,7 @@
#
# LAST UPDATED
#
# Thursday, July 22nd, 2021
# Friday, July 23rd, 2021
#
# ----------------------------------------------------------------------
......@@ -196,10 +196,19 @@ naked::install() {
wget "https://github.com/hpcng/singularity/releases/download/v${singularity_version}/singularity-${singularity_version}.tar.gz"
tar -xf "singularity-${singularity_version}.tar.gz"
cd singularity
./mconfig #--prefix=/opt/singularity
./mconfig #--prefix=/opt/singularity <- include prefix as used-defined option?
make -C ./builddir
make -C ./builddir install
# Prepend the path of the install directory of Singularity to PATH
# because not all secure_paths in /etc/sudoers may include it. If it
# is not included as one of the secure_paths by default, then the
# final install test below will fail erroneously, even when
# Singularity has been installed successfully.
#
# https://unix.stackexchange.com/questions/8646/why-are-path-variables-different-when-running-via-sudo-and-su
export PATH="/usr/local/bin:${PATH}"
log::output 'Checking if Singularity was installed successully ...'
singularity --version
if [[ "${?}" -ne 0 ]]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment