- Newest
- Most votes
- Most comments
source
is a shell command that interprets the file into your running shell; sudo source [...]
, even if spack didn't error out, isn't going to correctly set your shell environment.
I suggest starting an interactive shell as the owner of the spack
directory (probably root
), then sourcing the setup-env.sh
, and then running spack
commands. There spack
command is a misnomer, it's a shell function that correctly finds the underlying spack python entrypoint.
ssm-user# sudo /bin/su -
root # source /path/to/spack/setup-env.sh
root # spack install [...]
It seems you've encountered some issues with the Spack installation on your AWS ParallelCluster. Let's address these problems step by step to set up a correct environment:
-
The Spack installer script runs as a background task and can take 30 minutes or longer to complete, especially on smaller instance types. It's good that you've confirmed the successful completion of the installation.
-
The fact that Spack is not in your PATH by default is likely due to the environment not being properly set up. To fix this:
-
Add Spack to your PATH by adding this line to your ~/.bashrc file: export PATH=/shared/spack/bin:$PATH
-
Source your .bashrc file or log out and log back in for the changes to take effect.
- The issues with permissions and sudo access suggest that the Spack installation might not have the correct ownership or permissions. To resolve this:
-
Change the ownership of the Spack installation: sudo chown -R $USER:$USER /shared/spack
-
Ensure the Spack binary is executable: chmod +x /shared/spack/bin/spack
- For the Spack shell integration to work properly, you need to source the appropriate setup script. Add the following to your ~/.bashrc file:
source /shared/spack/share/spack/setup-env.sh
-
After making these changes, log out and log back in, or source your ~/.bashrc file.
-
Now you should be able to use Spack commands without specifying the full path, and the shell integration should work correctly.
-
If you still encounter issues with
spack env activate
, make sure you're using a shell that supports Spack's shell integration (bash, zsh, fish, or tcsh).
By following these steps, you should be able to set up a correct environment for using Spack on your AWS ParallelCluster. Remember to use the appropriate user account that has the necessary permissions to manage Spack and install packages.
If you continue to face issues, you may need to review the Spack installation process or consult AWS support for ParallelCluster-specific configurations.
Sources
Install optimized software with Spack configs for AWS ParallelCluster | AWS HPC Blog
Configuring AWS ParallelCluster - AWS ParallelCluster
I am afraid that LLMs are not sophisticated enough to answer these questions. I know how to set a PATH and source an env file. The problem is that the sudo command does not see it (not even with the -E option). The steps above will not help.
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a month ago
Thank you! Best practices normally require the use of sudo, rather than impersonating root. Perhaps you are right, and this is the only solution. I leave the question open, still hoping for a solution that uses sudo only.
As as comment to your comment, while
sudo
is best practice, recall that without a username (or constrained commands in/etc/sudoers
, your commands executed asroot
.If you're concerned about doing work as
root
(which is good!), I build my clusters with a specificspack:spack
UID and GID, and have/opt/spack
(or wherever the installation path is) owned byspack:spack
.I then become the
spack
user, interactively withsudo /bin/su - spack
andsource [...]setup-env.sh
. All installation, modification, etc. commands are run asspack
, unprivileged, so you can't accidentally change the operating system itself (asroot
might).Manually setting your
PATH
to thespack
binary (really, a python script) and calling withsudo
may succeed for some operations, as you noticed, but fails withload
/activate
since those are manipulating your shell environment.