-
Notifications
You must be signed in to change notification settings - Fork 8
bash nvm switching doesn't alter parent shell environment #11
Comments
This is what is executed: # reset to 5
kross:projects kross$ nvm use 5
Now using node v5.11.1 (npm v3.8.6)
kross:projects kross$ node -v
v5.11.1
# should update to 6.2
kross:projects kross$ cd nodengine/
v6.2.0 is already installed.
Now using node v6.2.0 (npm v3.8.9)
kross:nodengine kross$ node -v
v5.11.1
# exec the same _exact_ command manually
kross:nodengine kross$ bash -c 'source $NVM_DIR/nvm.sh; nvm install 6'
v6.2.0 is already installed.
Now using node v6.2.0 (npm v3.8.9)
kross:nodengine kross$ node -v
v5.11.1 So, I'm not up on bash semantics but the |
It's certainly possible I never had bash autoswitching working. While it execs the command and gives good output, the node version isn't sticking in the environment. I haven't yet found out why, and my current experiments haven't worked (yet). This is confirmed to be a bug with bash nvm switching, whether it is auto or manual. |
It seems a child_process cannot change a parent process's environment: And: So the stdout messages make you think you've got it right, but if you check with So far, I'm not sure this could ever work if we are spawning this command from node. |
I have a really terrible hack to get switching working. rosskevin@b3e1f1d
Perhaps someone savvier with bash can make something work, but what I found is that the child process cannot affect the parent environment, so So, definite bug using this with bash, no good workaround present, and my fork is not recommended. I'll need someone else to help out with this. |
We need a clean way to fix it or I could drop I'm using The point is, can you confirm me that is a problem related with
|
This is confirmed a problem with node + bash + nvm. I don't think it ever worked, even though stdout reported it ran. |
what do you think about use this https://github.com/wbyoung/avn-nvm/blob/master/index.js#L20 |
sounds strange because as you as seeing avn-nvm is using similar strategy |
Yes this looks virtually identical. I don't discount the idea that I've got something strange in my environment...and the fact that I thought it worked last week. BUT, based on the links I posted above about the inability for a child process to affect a parent process, the behavior I am currently seeing looks correct. With that said, the avn-nvm you shared wouldn't work either! So...I don't know. Do we have other bash users? Is it working for them? |
I'm switching to If someone else bumps into this, please speak up. |
Hey @rosskevin, I have the same report from another user: so finally spawn process is not affected parent in the nvm version, any idea? |
I think that could be possible... can you try? |
I think that also could be works using https://github.com/sindresorhus/execa |
Both using 5.7 and greater with the shell option and |
After @Kikobeats pointed it to me, I also encounter this issue. I'll let you know. |
@Kikobeats I tried many solutions (including the two mentionned in this issue) and I didn't managed to get this work. But please, don't drop support of NVM because of this 😄 Do you want me to try to implement something like this? |
Very strange, this stopped working around either nodengine 2.0.0 or node 6.2.0 release in the last few days.
It seems that after my switch to 2.0.0 (just a guess on timing), my nvm is not using my 6.2 version as it says.
I'll debug this further and report back.
The text was updated successfully, but these errors were encountered: