Skip to content
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 deactivate should clear all environment variables in NVM namespace #1399

Closed
leipert opened this issue Feb 14, 2017 · 4 comments
Closed
Assignees

Comments

@leipert
Copy link

leipert commented Feb 14, 2017

  • Operating system and version:
    OSX Sierra 10.12.3

  • nvm debug output:

nvm --version: v0.33.0
$SHELL: /usr/local/bin/zsh
$HOME: /Users/leipert
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v6.9.4
which node: $NVM_DIR/versions/node/v6.9.4/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v6.9.4/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v6.9.4
npm root -g: $NVM_DIR/versions/node/v6.9.4/lib/node_modules
  • nvm ls output:
->       v6.9.4
         v6.9.5
default -> v6.9.5
global -> stable (-> v6.9.5)
system -> stable (-> v6.9.5)
node -> stable (-> v6.9.5) (default)
stable -> 6.9 (-> v6.9.5) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> v6.9.5)
lts/argon -> v4.7.3 (-> N/A)
lts/boron -> v6.9.5
  • How did you install nvm? (e.g. install script in readme, homebrew):

README

  • What steps did you perform?
# returns nothing after shell starts
env | grep -i nvm
nvm use
# Undo effects of `nvm` on current shell
nvm deactivate
env | grep -i nvm
  • What happened?
NVM_CD_FLAGS=-q
NVM_DIR=/Users/leipert/.nvm
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
NVM_RC_VERSION=6.9.4
  • What did you expect to happen?

As per description of nvm deactivate I expected nvm to unset all environment variables related to nvm. Apparently this did not happen. Proposed solution, add this to nvm deactivate:

while read var; do unset $var; done < <(env | grep NVM_ | cut -d"=" -f1)
  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?

no

@ljharb
Copy link
Member

ljharb commented Feb 14, 2017

I think rather than dynamically listing the env vars in the implementation, I'll modify the existing test to do that.

@ljharb ljharb self-assigned this Feb 14, 2017
@ljharb
Copy link
Member

ljharb commented Feb 14, 2017

(I'd expect, however, NVM_DIR and the mirror variables to remain)

@leipert
Copy link
Author

leipert commented Feb 15, 2017

Thank you for your quick answer. A bit unrelated, but while your at it, after a nvm unload these nvm related variables still remain in env:

# nvm unload
# env | grep -i nvm
PATH=/Users/leipert/.nvm/versions/node/v6.9.5/bin:/usr/local/bin:/usr/local/sbin:
MANPATH=/Users/leipert/.nvm/versions/node/v6.9.5/share/man:/usr/local/opt/coreutils/libexec/gnuman
NVM_RC_VERSION=6.9.5

@ljharb
Copy link
Member

ljharb commented Feb 15, 2017

so actually nvm deactivate isn't what should remove the env vars; nvm unload is. nvm deactivate means you still want to use nvm again, you just want to remove its path modifications.

Certainly nvm unload should remove those other vars, as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants