-
Notifications
You must be signed in to change notification settings - Fork 130
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
Use sudo instead #94
Use sudo instead #94
Conversation
This works because sudo executes as another user, and the -i makes it a login shell which sets the proper $HOME variables. $_REMOTE_USER variable is fromm a proposal to the devcontainers spec https://github.com/devcontainers/spec/blob/main/proposals/features-user-env-variables.md
Shebang is (below), so we use that ```sh #!/bin/sh ```
This is a discussion tangentially related to this PR @danielbraun89 What are your thoughts? What do you think about piping to sh like # Basically do whatever the installer instructions say
curl ... | sh
curl ... | bash
curl ... | python3 # Programmer pre-inspects the file and see what the #!/usr/bin... header is
curl ... | /bin/sh
curl ... | /usr/bin/env bash # Use the hash-bang by downloading the file and 'chmod +x'-ing it
curl -o INSTALLFILE https://...
chmod +x INSTALLFILE
./INSTALLFILE I, personally, am all for just following the instructions given by whatever website. For this instance (Haskell), I think it should be # Install instructions from https://www.haskell.org/ghcup/#
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh |
probably following the instructions given by whatever website is safest? as it probably knew which shell is required for the specific syntax If it had a shebang in it, I guess it would be respected and replaced to it regardless of the shell you launched it with, so also good |
I'm a little torn because I see some trade-offs. Piping to a shell ( That said, my sense is that the priority in this repo is to optimize for simplicity and ease of maintenance since we want contributors and will likely only discover that a given Feature needs an update when an upstream dependency breaks the build. As such, I really ❤️ the link to the source of the install instructions and following it verbatim. If this Feature fails to install in the future, it will be very easy to check whether the GHCup folks have changed the install method. |
Hey @jcbhmr, I'm having a terrible time right now with getting different versions to install via the settings specified in My question to you: did you verify that if you set a value of |
Ah! No I did not verify that the # We run as the non-root user so to fix https://github.com/devcontainers-contrib/features/issues/80
# Note that we substitute SOME variables before evaluation, and some are
# substituted inside the $_REMOTE_USER shell. Particularily $HOME which needs to
# be from the $_REMOTE_USER, and $VERSION which needs to come from this script. https://github.com/devcontainers-contrib/features/blob/main/src/pulumi/install.sh#L30 Basically, it's because ENV vars don't pass through the sudo -iu "$_REMOTE_USER" <<EOF
export GHC_VERSION="$GHC_VERSION"
export CABAL_VERSION="$CABAL_VERSION"
export INCLUDE_STACK="$INCLUDE_STACK"
export ADJUST_BASHRC="$ADJUST_BASHRC"
export INSTALL_STACK_GHCUP_HOOK="$INSTALL_STACK_GHCUP_HOOK"
# Note that I can use a \$ to avoid substituting NOW and leave that the other shell pass to do
export STRING_WITH_DOLLAR_SIGN_IN_IT='\$GHC_VERSION'
EOF Think of it like JavaScript or Python's I can open a PR & issue to fix this. I should have caught this earlier 😡. Oh well! |
@jcbhmr, I was trying to pass them in with the Note that you don't need the env vars at the top, but the ones set in features/src/haskell/install.sh Lines 31 to 45 in 0495b96
One gotcha I can test is that the so-called boolean vars are true if set, so we'll need to make sure they don't get set to true simply by being included in the list. |
Closes #85 with @jcbhmr's changes.