-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
nvm not available in non-interactive shells #1718
Comments
|
@ljharb Hey Jordan, no problem. I get that. But it doesn't show up in non-interactive shells, so it can't be scripted. I noticed a What about a The installer could link this into ~/bin or if no directory explain what to do. |
I'd also like it to show up in non-interactive shells. In my example, I have a Docker image with NVM installed on a certain user. I'd like to start a new container and have NVM sourced when starting. |
@MichaelJCole that's exactly what |
Aha! Great! Ok @ljharb , that's the same direction. For whatever reason, nvm works great, but nvm-exec returns no output. Sunshine means command succeeded. Umbrella w/ rain means the command returned a failure code to the shell. Am I using it wrong? Or did I miss some documentation?
|
That's because you're running |
@ljharb I think
|
@MichaelJCole that’s how it’s supposed to work. It takes an arbitrary command and executes it with a particular version of node |
@ljharb How do I use nvm in a non-interactive shell without having to source it each time? |
I mean, really, you don't - one way or another, However, if you execute |
@ljharb ok, this isn't fitting my model, but that's ok. For most projects, I've got a
Looking at this again, I'm whining about the first parts of the first line. So maybe not a big deal. Mostly, it's not very new developer friendly. Do you have any suggestions or do you see a better way? Thanks! |
I don't think there's a better way, no (altho the |
Ok, cool. Thanks! |
I would like to use "nvm use" in my cron scripts and am unable to run it. Neither
@ljharb what's the correct way to do this? |
@JimLynchCodes your cron scripts need to source nvm.sh to be able to use nvm. |
To run nvm use via ssh remote command as part of a deployment script doing as ljharb commented makes it work. source ~/.nvm/nvm.sh
nvm use v12.4.0 sshCommands="$(cat <<END_HEREDOC
# Install api server dependencies.
source ~/.nvm/nvm.sh
echo "Switching to appropriate node.js version using nvm"
if ! nvm use v12.4.0 ; then
echo "Error using nvm to switch node.js version."
exit 14
fi
echo "Installing server api dependencies"
if ! yarn ; then
echo "Error installing server api dependencies."
#exit 15
fi
END_HEREDOC
)"
ssh ${deploymentUsername}@${deploymentHost} -t "$sshCommands" |
* Reading nvm-sh/nvm#1718 suggests that we need source the nvm.sh file in order for nvm to work/apply before executing other commands in a non-interactive shell.
In windows I had to do this
Where Then I restarted the Jenkins server |
@promisepreston nvm does not support windows, unless you're using WSL. Perhaps you're using nvm-windows, a different project? |
See #1717 for installation details. Sorry if you already know these shell details - I had to review them to write this up.
Interactive shells are typed into. E.g. typing the command
nvm
at the flashing cursor.This bug is about nvm not being available in non-interactive shells. E.g. this test.sh:
This is because
nvm
isn't on the path, which probably causes alot of other bugs.Linking nvm.sh into the path doesn't work because nvm.sh doesn't appear to do anything when run directly:
So, I'm a bit stuck on how to use nvm non-interactively and have to put this crufty code everywhere:
Which is kind of annoying. It would be nice if nvm was actually installed onto the path.
The text was updated successfully, but these errors were encountered: