Closed maturanomx closed 8 years ago
Thanks for reporting π
Looking into it now.
@maturano Do you have lazy loading enabled?
export NVM_LAZY_LOAD=true
@lukechilds Yes I do :)
Sweet, almost got a fix π
Btw, was it just:
basename: missing operand
Try 'basename --help' for more information.
that you are getting on every new terminal or are you getting the Installing nvm..
@maturano The issue was caused by the lazy loading code. I grab a list of all the global modules and then format them into an ordered array of unique basenames. I wasn't checking if I actually had any items in the list before trying to run basename
so if you didn't have any globals (no versions of node after a fresh install) it would run basename
against an empty string, hence the basename: missing operand
error.
I'm checking if we have any globals before trying to format them now: https://github.com/lukechilds/zsh-nvm/commit/007fd93fd71d6bcb12a0a688f47c9e9f58fdbaff
If you run zplug update
you should be golden π
@maturano Let me know if thats resolved it so I can close the issue π
First, I had not installed any node version and I was just getting
basename: missing operand
Try 'basename --help' for more information.
Now, I update the plugin:
$ zplug update
Updated! lukechilds/zsh-nvm (3.55s)
open a new terminal and I get this:
basename: extra operand β/home/maturano/.nvm/versions/node/v4.5.0/bin/nodeβ
Try 'basename --help' for more information.
But, as you can deduce, I installed node 4.5.0 with nvm. Let me do a fresh install :)
Clean install:
After nvm install --lts node
, in new terminal:
_zsh_nvm_global_binaries:local:3: not valid in this context: /home/maturano/.nvm/versions/node/v4.5.0/bin/npm
Hmmn, looks like it was caused by missing quotes: https://github.com/lukechilds/zsh-nvm/commit/ce7bc2a0a2d6439a0e3a9ab38309a527d74ade60
Can you try again after another zplug update
.
Weird though, it works without the quotes on my MacBook. Might be a zsh version thing, I'm on 5.2. Getting the same issue as you on an Ubuntu VM with zsh 5.0.2.
After update: no message, but LAZY_LOAD stop working: always load node :)
What do you mean by not working?
If lazy loading is working properly it should appear as though node is loaded. It's not actually loaded it's just a shell function called "node
" that will load nvm
and then run node
when called.
You can check if it's working properly by running the following straight after starting a new session:
vagrant-ubuntu-trusty-64% type node
node is a shell function
vagrant-ubuntu-trusty-64% node --version
v4.5.0
vagrant-ubuntu-trusty-64% type node
node is /home/vagrant/.nvm/versions/node/v4.5.0/bin/node
With .zshrc
like:
NVM_LAZY_LOAD=true
zplug "johnhamelink/rvm-zsh"
Opening new terminal on commit 007fd93 :
_zsh_nvm_global_binaries:local:3: not valid in this context: /home/maturano/.nvm/versions/node/v4.5.0/bin/npm
~ $ node --version
zsh: command not found: node
Opening new terminal on commit ce7bc2a0a2d6439a0e3a9ab38309a527d74ade60 :
# (Clean, no message)
$ node --version
v4.5.0
I hope explain better now :smile:
That looks like it's working π
Start a new session and run this to check:
type node && node --version && type node
If it's working you should get:
vagrant-ubuntu-trusty-64% type node && node --version && type node
node is a shell function
v4.5.0
node is /home/vagrant/.nvm/versions/node/v4.5.0/bin/node
I'm getting the same output but, let me give more context:
I don't use node
all the time, that's why I also have the autoenv plugin to load node
(and/or others virtual enviroments) just when I needed. I use the powerlevel9k theme to display my enviroment.
On commit 007fd93 this is what I get:
I don't have node
, my enviroment is clean.
With the las commit ( ce7bc2a ), this is what I get:
Apparently, load node automatically :confused: ... That's what I tried to avoid with the NVM_LAZY_LOAD
option.
Ah I see. As of commit https://github.com/lukechilds/zsh-nvm/commit/ce7bc2a0a2d6439a0e3a9ab38309a527d74ade60 everything is working correctly. Lazy loading is working properly, that's why the first time you run type node
you get node is a shell function
. This means node is not loaded.
Lazy loading works by creating shell functions for all of your node globals. Node isn't loaded. Then when one of those shell functions is called, nvm is loaded along with node and the global you tried to run is executed.
I would guess that your theme is checking if node is enabled by running node --version
and if it gets output, showing the output as the currently loaded node version. With lazy loading enabled node won't be loaded until you run node
. Running node --version
will then cause node to be loaded.
Your theme is probably doing this in a sub process so node is loaded in the sub process and not in your main process. That's why the lazy load test command I gave you says node isn't loaded at first but your theme thinks it is.
So to clarify, lazy loading is now working as expected. The issue with your theme is completely unrelated.
Just checked the theme, it is indeed checking the node version in a sub process: https://github.com/bhilburn/powerlevel9k/blob/c4fdc8f70804fea6f543e6bbf3964301e2537e36/powerlevel9k.zsh-theme#L615-L621
I'm going to close this issue now because the original problem is resolved (thanks for your help debugging).
Feel free to open a new issue about compatibility issues between zsh-nvm and powerlevel9k. It should be pretty easy to fix with a PR to powerlevel9k.
@maturano I've just created this issue: https://github.com/lukechilds/zsh-nvm/issues/9
This will allow nvm
to work how you want, meaning no node
versions are loaded until you explicitly load them. Should be pretty easy to implement, hoping to have it done in the next couple of days.
That will be excellent @lukechilds !!! :smiley:
After installation using zplug, I'm getting this message on every new terminal
This is the output of
zplug load
:Env: zsh 5.0.2 (x86_64-pc-linux-gnu) on Ubuntu 14.04.5 LTS