summaryrefslogtreecommitdiff
path: root/share/spack/setup-env.sh
AgeCommit message (Collapse)AuthorFilesLines
2020-05-13Added alias and bash completion for spacktivate (#16472)Ben Bergen1-0/+2
2020-04-16macos: use DYLD_FALLBACK_LIBRARY_PATH instead of DYLD_LIBRARY_PATHTodd Gamblin1-7/+4
`DYLD_LIBRARY_PATH` can frequently break builtin macOS software when pointed at Spack libraries. This is because it takes *higher* precedence than the default library search paths, which are used by system software. `DYLD_FALLBACK_LIBRARY_PATH`, on the other hand, takes lower precedence. At first glance, this might seem bad, because the software installed by Spack in an environment needs to find *its* libraries, and it should not use the defaults. However, Spack's isntallations are always `RPATH`'d, so they do not have this problem. `DYLD_FALLBACK_LIBRARY_PATH` is thus useful for things built in an environment that need to use Spack's libraries, that don't set *their* RPATHs correctly for whatever reason. We now prefer it to `DYLD_LIBRARY_PATH` in modules and in environments because it helps a little bit, and it is much less intrusive.
2020-03-31Allow Spack Environments with '-h' in the name (#15429)Adam J. Stewart1-17/+32
If a user invoked "spack env activate example-henv", Spack would mistakenly interpret the "-h" from "example-henv" as the "-h" option. This commit allows users to create and activate environments with "-h" in the name. This issue existed for bash shell support as well as csh support, and this commit addresses both, along with some other unrelated csh support issues.
2020-02-13Fix shell detection: zsh5 -> zsh (#14858)Adam J. Stewart1-1/+2
2020-01-22shell support: `spack load` no longer needs modules (#14062)Greg Becker1-35/+26
Previously the `spack load` command was a wrapper around `module load`. This required some bootstrapping of modules to make `spack load` work properly. With this PR, the `spack` shell function handles the environment modifications necessary to add packages to your user environment. This removes the dependence on environment modules or lmod and removes the requirement to bootstrap spack (beyond using the setup-env scripts). Included in this PR is support for MacOS when using Apple's System Integrity Protection (SIP), which is enabled by default in modern MacOS versions. SIP clears the `LD_LIBRARY_PATH` and `DYLD_LIBRARY_PATH` variables on process startup for executables that live in `/usr` (but not '/usr/local', `/System`, `/bin`, and `/sbin` among other system locations. Spack cannot know the `LD_LIBRARY_PATH` of the calling process when executed using `/bin/sh` and `/usr/bin/python`. The `spack` shell function now manually forwards these two variables, if they are present, as `SPACK_<VAR>` and recovers those values on startup. - [x] spack load/unload no longer delegate to modules - [x] refactor user_environment modification calculations - [x] update documentation for spack load/unload Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2020-01-14stop word splitting from leaking out of setup-env (#14472)Tom Scogland1-1/+1
The pathadd function was using setopt to configure zsh for word splitting, which leaks out of the function and breaks default functionality in a number of external zsh plugins and packages. This switches to emulate -L, just as the spack function uses, to keep the setting local to the function.
2019-12-30copyright: update copyright dates for 2020 (#14328)Todd Gamblin1-1/+1
2019-12-16Harden shell detection when procfs is available (#13950)Massimiliano Culpo1-3/+6
2019-10-02Remove support for generating dotkit files (#11986)Massimiliano Culpo1-26/+11
Dotkit is being used only at a few sites and has been deprecated on new machines. This commit removes all the code that provide support for the generation of dotkit module files. A new validator named "deprecatedProperties" has been added to the jsonschema validators. It permits to prompt a warning message or exit with an error if a property that has been marked as deprecated is encountered. * Removed references to dotkit in the docs * Removed references to dotkit in setup-env-test.sh * Added a unit test for the 'deprecatedProperties' schema validator
2019-10-01Add all compatible system types directory to module pathsMassimiliano Culpo1-1/+3
fixes #12915 closes #12916 Since Spack has support for specific targets it might happen that software is built for targets that are not exactly the host because it was either an explicit user request or the compiler being used is too old to support the host. Modules for different targets are written into different directories and by default Spack was adding to MODULEPATH only the directory corresponding to the current host. This PR modifies this behavior to add all the directories that are **compatible** with the current host.
2019-07-15bugfix: fix module() function in setup-env.sh (#12030)Todd Gamblin1-6/+9
Modify `setup-env.sh` to export fewer variables but to still set the module() function correctly.
2019-07-12bugfix: setup-env.sh detects bash even when bash is run as sh (#11994)Todd Gamblin1-7/+2
- `setup-env.sh` was not properly detecting a bash shell when bash was run as /bin/sh. - Detection routine now always reports bash when bash is run as sh, and no longer parses the path to the executable indicated in `$BASH`.
2019-07-05setup-env.sh: make setup scripts work with `set -u`Todd Gamblin1-4/+8
- Add set -u to the setup-env.sh test script - Refactor lines in setup-env.sh that tested potentially undefined variables to use the `[ -z ${var+x} ]` construct
2019-07-05setup-env.sh: now compatible with bash, zsh, and dashTodd Gamblin1-65/+114
- replace use of [[ with [ - replace function foo { .. } with foo() { .. } - wrap some long lines - add lsof and /proc/fd magic so that we can find the sourced file even in dash - only do the complicated shell checks in one place; test $_sp_shell elsewhere.
2019-06-29setup-env.sh: send cd output to /dev/null when it affects SpackTodd Gamblin1-9/+12
- We've seen this a few times now where users have set up `cd` to echo the new directory, and it screws up `setup-env.sh` - In the past we've said this is user error. - Here, we just fix it by sending `cd` output to /dev/null where needed. - this works in bash, zsh, and dash
2019-04-24Fix handling of MODULEPATH in setup-env.sh (#11274)Toyohisa Kameyama1-1/+1
Usage of double quotes was preventing word-splitting when parsing module roots in setup-env.sh, which lead to an error when multiple module roots are used (in particular when Spack is pointed to use an upstream module root in addition to its own).
2019-04-16setup-env.sh: fix zsh compatibility error (#11153)paulanda1-3/+3
Still look for BASH_SOURCE[0] first, but if it's not set, _sp_source_file is initialized to an empty value addressing the unset parameter error (line 217).
2019-03-27spack chain (#8772)Peter Scheibel1-2/+11
* initial work to make use of an 'upstream' spack installation: this uses the DB of the upstream installation to check if a package is installed * need to query upstream dbs when adding new record to local db * prevent reindexing upstream DBs * set prefix on specs read from DB based on path stored in install record * check that Spack does not install packages that are recorded as installed in an upstream db * externals do not add their path to install records - need to use 'external_path' to get path of upstream externals * views need to check for upstream installations when linking metadata * package and spec now calculate upstream installation properties on-demand themselves rather than depending on concretization to set these properties up-front. The added tests for upstream installations don't work with this new strategy so they need to be updated * only refresh modules for local specs (not those in upstream packages); optionally generate local module files for packages installed upstream * when a user tries to locate a module file for a package installed upstream, tell them to use the upstream spack instance to locate it * support recursive upstream databases (allow upstream databases to use their own upstream databases) * separate upstream config into separate file with its own schema; each entry now also includes a name * metadata_dir is no longer customizable on a per-instance basis for YamlDirectoryLayout * treat metadata_dir as an instance variable but dont set it from kwargs; this follows several other hardcoded variables which must be consistent between upstream and downstream DBs. Also update DirectoryLayout.metadata_path to work entirely with Spec.prefix, since Spec.prefix is set from the DB when available (so metadata_path was duplicating that logic)
2019-02-28Fix shell integration with environment-modules@4 (#10736)Michael Kuhn1-4/+10
2019-02-13make SPACK_SHELL detection more robust (#9712)Phil Carns1-1/+12
Spack shell detection in setup-env.sh was originally based on examining the executable name of $$ (from "ps"). In some cases this does not actually give the name of the shell used, for example when setup-env.sh was invoked from a script using "#!". To make shell detection more robust, this adds a preliminary check for shell variables which indicate that the shell is bash or zsh; the executable name of $$ is retained as a fallback if those variables are not defined.
2019-01-01copyright: update license headers for 2013-2019 copyright.Todd Gamblin1-1/+1
2018-12-15env setup: support --help for cd/env commands (#10069)Matthias Diener1-2/+2
2018-11-09env: environments can be named or created in directoriesTodd Gamblin1-2/+3
- `spack env create <name>` works as before - `spack env create <path>` now works as well -- environments can be created in their own directories outside of Spack. - `spack install` will look for a `spack.yaml` file in the current directory, and will install the entire project from the environment - The Environment class has been refactored so that it does not depend on the internal Spack environment root; it just takes a path and operates on an environment in that path (so internal and external envs are handled the same) - The named environment interface has been hoisted to the spack.environment module level. - env.yaml is now spack.yaml in all places. It was easier to go with one name for these files than to try to handle logic for both env.yaml and spack.yaml.
2018-11-09env: add spack env activate/deactivate and shell supportTodd Gamblin1-0/+36
- `spack env activate foo`: sets SPACK_ENV to the current active env name - `spack env deactivate`: unsets SPACK_ENV, deactivates the environment - added support to setup_env.sh and setup_env.csh - other env commands work properly with SPACK_ENV, as with an environment arguments. - command-line --env arguments take precedence over the active environment, if given.
2018-10-29setup-env: Avoid different output format of `ps` (#9629)Bert Wesarg1-1/+1
setup-env includes a call to 'ps' to determine what shell is being used. 'ps' can be instructed to use a different default output format via the 'PS_FORMAT' env variable. Thus unset this variable before calling 'ps'.
2018-10-17relicense: replace LGPL headers with Apache-2.0/MIT SPDX headersTodd Gamblin1-23/+4
- remove the old LGPL license headers from all files in Spack - add SPDX headers to all files - core and most packages are (Apache-2.0 OR MIT) - a very small number of remaining packages are LGPL-2.1-only
2018-07-27Fix shift warning on zsh (#8805)Michael Kuhn1-2/+10
When using zsh, trying to shift when there are no arguments left results in warnings like this: spack:shift:22: shift count must be <= $#
2018-07-24Grouped all the module commands under `spack module`Massimiliano Culpo1-4/+4
As requested in the review all the commands meant to manage module files have been grouped under the `spack module` command. Unit tests have been refactored to match the new command structure.
2018-07-24spack load exits with 1 if module does not exist or is not installedMassimiliano Culpo1-0/+8
fixes #2215 fixes #2570 fixes #6676 fixes #7281 closes #3827 This PR reverts the use of `spack module loads` in favor of `spack module find` when loading module files via Spack. After this PR `spack load` will accept a single spec at a time, and will be able to interpret correctly the `--dependencies` option.
2018-07-24Revert "Fix recursive module loading."Massimiliano Culpo1-4/+4
This reverts commit 732c24f603864ec7dbec425ac4507b47fdb7a641.
2018-07-16add `spack --print-shell-vars` to speed up `setup-env.[c]sh` (#8101)Todd Gamblin1-17/+10
- The setup-env.sh script currently makes two calls to spack, but it should only need to make one. - Add a fast-path shell setup routine in `main.py` to allow the shell setup to happen in a single, fast call that doesn't load more than it needs to. - This simplifies setup code, as it has to eval what Spack prints - TODO: consider eventually making the whole setup script the output of a spack command
2018-05-17config: simplify configuration API to just get and setTodd Gamblin1-2/+2
- replace `spack.config.get_configuration()` with `spack.config.config()` - replace `get_config`/`update_config` with `get`, `set` - add a path syntax that can be used to refer to specific config options without firt getting the entire configuration dict - update usages of `get_config` and `update_config` to use `get` and `set`
2018-04-24environment shell: fix `spack load` (#7747)René Widera1-6/+6
Fix `spack load` with extended packe specifications those includes spaces. Solved by using perfectly parameter forwarding via temporary array. example: ``` $ spack install zlib $ spack install zlib cppflags='-O3 -march=native' $ spack install zlib cppflags='-O2 -march=native' $ spack find -d -L -f zlib ==> 3 installed packages. -- linux-linuxmint18-x86_64 / gcc@5.4.0 ------------------------- k5hg4kkxiutkfl6n53ogz5wnlbdrsdtf zlib@1.2.11%gcc mse2fyzdxciszdhiqi4b5kl6fxkps3fh zlib@1.2.11%gcc cppflags="-O2 -march=native" vrnvj2fikcbxqxrymctnlpmud7wbuahk zlib@1.2.11%gcc cppflags="-O3 -march=native" $ spack load zlib cppflags='-O3 -march=native' ==> Error: Unexpected token ['zlib', 'cppflags=-O3', '-march=native'] ```
2018-03-24Update copyright on LLNL files for 2018. (#7592)Todd Gamblin1-1/+1
2017-11-15Reduce the calls to the python interpreter during initialization (#6312)Massimiliano Culpo1-3/+10
* Reduce the calls to the python interpreter during initialization This should reduce the delay the users experience when sourcing the setup file to activate shell support. It works by generating at once all the commands that needs to evaluated (they are stored in a string and later `eval`ed by the shell). * setup_env.sh: changed `read` with an equivalent magic For some reason `read` breaks when sourced from a running script. Change the incantation we use to construct the unique python command that will be evaluated. * setup_env.sh: python command now constructed with `printf` for portability This recovers the support for `zsh` that was broken in previous commits.
2017-11-04Replace github.com/llnl/spack with github.com/spack/spack (#6142)Todd Gamblin1-1/+1
We moved to a new GitHub org! Now make the code and docs reflect that.
2017-09-26Set LANG= for _spack_fn_exists (#5475)Michael Kuhn1-1/+1
type's output can be localized, causing the grep to fail.
2017-09-14Remove echo statements from setup-env.shMatthew Scott Krafczyk1-11/+0
setup-env.sh adds the 'module' command to the user's environment if it is not defined and if there is a Spack installation of environment-modules available. This commit updates that logic to perform these checks and updates quietly.
2017-09-12Shell detection: filter preceding "-"Christoph Junghans1-1/+1
On OSX, the shell detection code may get a preceding dash, like "-bash". This adds a filter to remove it.
2017-09-10Fix two bugs from the bootstrap update (#5312)Matthew Scott Krafczyk1-6/+6
These were discovered with bash 4.1.2. Add quotations around a variable to prevent the destruction of a newline. Without this fix a conditional doesn't work properly. Remove square brackets around a conditional meant to be evaluated based on the return code of a command. This wasn't working properly with an old bash. Fix a typo.
2017-09-08Bootstrap environment-modulesMatthew Scott Krafczyk1-3/+54
Renames the existing bootstrap command to 'clone'. Repurposes 'spack bootstrap' to install packages that are useful to the operation of Spack (for now this is just environment-modules). For bash and ksh users running setup-env.sh, if a Spack-installed instance of environment-modules is detected and environment modules and dotkit are not externally available, Spack will define the 'module' command in the user's shell to use the environment-modules built by Spack.
2017-09-06Update copyright notices for 2017 (#5295)Michael Kuhn1-1/+1
2017-06-28Return an error exit code if spack cd does not succeed. (#4623)Jon Rood1-0/+2
* Return an error exit code if spack cd does not succeed. * Reducing amount of return statements in spack cd exit code.
2017-06-24Make LICENSE recognizable by GitHub. (#4598)Todd Gamblin1-1/+1
2017-04-20Revert "Add lmod files to MODULEPATH" (#3917)Todd Gamblin1-2/+0
* Revert "Add lmod files to MODULEPATH (#3912)" This reverts commit 186d1f4511c8aa3bc5ce661b1e883db10e20958a.
2017-04-19Add lmod files to MODULEPATH (#3912)Adam J. Stewart1-0/+2
2017-02-06Bash Programmable Completion for Spack (#3026)Adam J. Stewart1-0/+7
2017-01-23Export spack function so it works in subshells (#2908)Michael Kuhn1-0/+5
2016-11-29Allow shell support to work when set -u is set (#2418)Adam J. Stewart1-1/+1
2016-11-04setup script for bash : fixes #2209 for sh setup (#2212)Massimiliano Culpo1-2/+4