-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make setup-env.sh compatible with dash #4048
Conversation
I agree with making the script more POSIX compatible. I might as well close #3736 then, as it introduces a lot of Bashisms. This checkbashisms script might be useful for testing purposes. We can also add a package for dash for testing. |
Generally looks like an improvement. Any reason not to swap |
5b6167e
to
d16c9ea
Compare
d16c9ea
to
d51f0b5
Compare
I'd recommend using ShellCheck to check for other bad patterns. |
ShellCheck looks useful, but we may also want to include unit tests to make sure PRs don't break dash support. We should also consider making this change to the compiler wrappers as well. This could create a serious speed up of installation times on systems where /bin/sh links to dash. |
Accidental change was removed so I'm happy. Haven't yet tested this with dash though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a nice one to have for 0.12.0
Fixes to allow for external Spack in Mason The main aim here is to allow for an external Spack installation. If SPACK_ROOT is set, then the code uses that, instead of installing a new version. A few other minor fixes : - When spawning a shell, we quote the PATH values to allow for spaces. - Use . instead of source to run setup-env.sh to be POSIX compliant (especially on Ubuntu/Debian systems) - Unfortunately, Spack's setup-env.sh uses bashisms (this is spack/spack#4048), but for now, we work around this by always using bash [Contributed by @npadmana] [Reviewed by @ben-albrecht && @Spartee]
Hi! I'm trying to use spack to install blitz on Ubuntu 18.04. After doing this:
I get this error: Would this pull request be a solution to my problem? Is there a chance for it to be merged? Or is there any workaround for me? Thanks! |
d2bbd4b
to
6b2accc
Compare
@trontrytel: I rebased this PR on |
@citibeth: yes, it's still relevant. |
Ok, this PR is updated and seems to actually work. In particular:
The second one was rather surprising to me, but after googling around some, it turns out The combination of the two techniques seems like it'll work on either stock macos or on most stock Linux containers, if you happen to be running We probably need to add some tests that just source this file in containers and make sure everything is set up properly. |
Hi @tgamblin. Thanks for looking into this. It works now (tested in vagrant on ubuntu 18.04) For some reason when doing the same in vagrant while building a singularity image I got a lot of prints from spack (see below). But it seems to be working.
|
@trontrytel: Awesome! It looks like vagrant might |
d89cd1d
to
02863ed
Compare
3d8855d
to
035efed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All minor requests:
- 2 requests about comments
- 1 typo
checkbashisms
doesn't report any bash-specific syntax (that is not guarded by a bash-shell check). Running the tests with sh
would be ideal except that it apparently usually links to bash
(or in my Ubuntu docker instance to dash
). dash
is arguably bare-bones enough that running the tests with it is sufficient to establish sh
-compatibility.
035efed
to
ea5df69
Compare
- 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.
ea5df69
to
e76990d
Compare
- tests use a shell-script harness and test all Spack commands that require special shell support. - tests work in bash, zsh, and dash - run setup-env.sh tests on macos and linux builds. - we run them on macos and linux
- 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
e76990d
to
5385dfa
Compare
I thought |
IMO the best way to proceed is to change something if someone reports an issue with it when running with |
I thought $(...) was also a Bash-ism, but I see a lot of that in our scripts. Shouldn't we use `...`?
That’s a common misconception, that I used to hold as well actually, “$(...)” has been part of shell scripting since posix 1, so short of dealing with pre-posix sh it should be fine.
|
What @trws said -- it's standard POSIX.
I think these are good ideas, but note also that the tests introduced here actually run setup-env.sh with |
Yeah, I'm glad dash is so strict, makes testing really easy. |
…es is a callable function closes spack#4048
On the latest Ubuntu and Debian, and on Arch, the default system shell is
dash
, and there are systems out there that don't havebash
. See Arch and Ubuntu's docs on this.If you run as Spack in those environments, you get this:
This PR makes
setup-env.sh
dash
-compatible 😄 . And less readable 😞 . I think it is worthwhile to besh
-compatible so that we can be used easily in these more and more popular minimal environments.[[
with[
function foo { .. }
withfoo() { .. }
dash
(whoa!)$_sp_shell
elsewhere.