nvm: Attempting to source nvm from within a ruby script does not seem to use parent shell

  • Operating system and version: MacOS 10.12.5

  • nvm debug output: no debug output, the script won’t load

  • nvm ls output: no ls output, the script won’t load

  • How did you install nvm? (e.g. install script in readme, homebrew): I don’t remember. Probably zsh-nvm

  • What steps did you perform? I’ve added

  system %{
    . ~/.nvm/nvm.sh
    nvm use 4.5.0
    npm install
  }

to a Rakefile. Running the rakefile results in the following error:

/Users/tylerthrailkill/.nvm/nvm.sh: line 27: cd: -q: invalid option
cd: usage: cd [-L|-P] [dir]
N/A: version "4.5.0 -> N/A" is not yet installed.

With my own debugging I don’t understand why -q is not a valid option, since I’m running in a zsh, and I’ve verified SHELL is zsh.

  • What happened? nvm won’t load

  • What did you expect to happen? nvm to load, since I’m running the rakefile from a zsh, it should run consistently in that shell.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH? Yes, lots, but I’ve verified through modifying the nvm.sh file to printenv to show that I’m in the proper shell with the property stuff set. Here is that output

AUTOJUMP_ERROR_PATH=/Users/tylerthrailkill/Library/autojump/errors.log
MANPATH=/Users/tylerthrailkill/.nvm/versions/node/v7.3.0/share/man:/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:
TERM_PROGRAM=iTerm.app
NVM_CD_FLAGS=-q
AUTOJUMP_SOURCED=1
TERM=xterm-256color
SHELL=/usr/local/bin/zsh
CLICOLOR=true
TMPDIR=/var/folders/mk/lvf9cfc57ss2fym_pdcz_t400000gn/T/
GRADLE_HOME=/Users/tylerthrailkill/Applications/ActiveVersions/Gradle
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.j6fEZlOD3E/Render
TERM_PROGRAM_VERSION=3.0.15
TERM_SESSION_ID=w0t3p0:F59F1C90-B51C-4D10-A132-EE9D008A7CA9
PHANTOM_JS=/Users/tylerthrailkill/Applications/ActiveVersions/PhantomJS
ZSH=/Users/tylerthrailkill/.oh-my-zsh
USER=tylerthrailkill
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.OhYNsonF3t/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
VIRTUAL_ENV_DISABLE_PROMPT=1
PAGER=less
DOTFILES=/Users/tylerthrailkill/.dotfiles
LSCOLORS=exfxcxdxbxegedabagacad
PATH=/Users/tylerthrailkill/.nvm/versions/node/v7.3.0/bin:/Users/tylerthrailkill/Applications/ActiveVersions/Maven/bin:/Users/tylerthrailkill/Applications/ActiveVersions/Gradle/bin:/Users/tylerthrailkill/Applications/ActiveVersions/PhantomJS/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
PWD=/Users/tylerthrailkill/Documents/dev/code/borrower-wallet-ui
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
EDITOR=vim
LANG=en_US.UTF-8
ITERM_PROFILE=Tyler
XPC_FLAGS=0x0
NVM_LAZY_LOAD=true
XPC_SERVICE_NAME=0
M2_HOME=/Users/tylerthrailkill/Applications/ActiveVersions/Maven
SHLVL=2
HOME=/Users/tylerthrailkill
COLORFGBG=15;0
ITERM_SESSION_ID=w0t3p0:F59F1C90-B51C-4D10-A132-EE9D008A7CA9
LESS=-R
LOGNAME=tylerthrailkill
LC_CTYPE=en_US.UTF-8
NVM_BIN=/Users/tylerthrailkill/.nvm/versions/node/v7.3.0/bin
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
PROMPT_EOL_MARK=
_=/usr/bin/printenv

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Ok, give me a few minutes then.

Yes I can. Thank you for your help.

Everything works perfectly if I remove zsh-nvm from plugins=(otherpluginshere...)