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

Lazy: Take precedence over preinstalled node #15

Closed
SimenB opened this issue Dec 16, 2016 · 18 comments
Closed

Lazy: Take precedence over preinstalled node #15

SimenB opened this issue Dec 16, 2016 · 18 comments
Assignees

Comments

@SimenB
Copy link

SimenB commented Dec 16, 2016

I installed yarn through brew instead of npm (as it's recommended that way), but since Yarn in brew depends on node, that gets installed as well, and using node or npm doesn't load nvm any more.

@lukechilds
Copy link
Owner

Hmmn, it would appear that the node and npm binaries are taking priority over the lazy loader functions.

Could you start a new session and let me know what which node outputs. Also if you have any globally installed modules running which <module name> would be helpful. Thanks :)

@lukechilds
Copy link
Owner

lukechilds commented Dec 16, 2016

I just installed yarn through brew and I get:

$ which node
/usr/local/bin/node

So the brew node binary does have a higher priority than the lazy loader node function. I'm not quite sure why, I thought functions should have priority over PATH binaries. If I create a function in the session it does take priority:

$ which node
/usr/local/bin/node
$ node() { echo node }
$ which node
node () {
	echo node
}

If I brew uninstall yarn, node and npm, then npm install -g yarn it works.

@SimenB
Copy link
Author

SimenB commented Dec 16, 2016

Since you can reproduce, I don't need to run which? It's on another machine, so it's just a bit more work than no work at all 😆

@lukechilds
Copy link
Owner

Yep, I've done it haha

@lukechilds
Copy link
Owner

You can also disable NVM_LAZY_LOAD and then zsh-nvm and brew node can live together happily.

So you need to choose:

  • brew install yarn and NVM_LAZY_LOAD=false
  • npm install -g yarn and NVM_LAZY_LOAD=true

To clarify, the issue appears to be caused by brew node, I'm not quite sure how it's overriding the lazy load function. If I can figure out I may be able to get them to work together but I would suggest using one of the two options above :)

@lukechilds
Copy link
Owner

Found the conflict!

Working on a fix...

@lukechilds
Copy link
Owner

It was caused by the fix for the issue you pointed out before when the name of a global node module is already in use.

I should be able to just whitelist node and npm from that list as we always know we want our versions to take precedence.

@SimenB
Copy link
Author

SimenB commented Dec 16, 2016

So it's kinda my fault? Cool! 😁

But yeah, adding node and npm to cmds at creation time makes sense to me, at least

@lukechilds
Copy link
Owner

Haha no it's not your fault, you just seem to be really good at finding edge cases in my code 😆

Should have a fix shortly...

@lukechilds
Copy link
Owner

I've updated the fix from the other issue to specifically check for aliases rather than any binary/alias/function. That seems to have done the job.

@lukechilds
Copy link
Owner

@SimenB Let me know if this works for you :)

@lukechilds lukechilds self-assigned this Dec 16, 2016
@SimenB
Copy link
Author

SimenB commented Dec 16, 2016

It works! Thanks.

I did figure out I could do brew install yarn --ignore-dependencies. I then get env: node: No such file or directory 😁 Is it possible for me to append a custom command to the array you check? Say I did NVM_LOAD_CMDS=(yarn) or something?

@lukechilds
Copy link
Owner

Great, thanks for raising the issue!

Sorry, I'm not too sure what you're asking for re the array. If you want to lazy load yarn I don't think that's gonna be possible because that's all handled with homebrew symlinks.

@SimenB
Copy link
Author

SimenB commented Dec 16, 2016

I don't want to lazy load yarn, but yarn depends on node, which is lazy loaded. So I want your same wrapper to include yarn (that is, load up nvm so Node is loaded)

@lukechilds
Copy link
Owner

Ahhhh, I see.

Yeah that would be possible although I'm kinda reluctant to do that. It's not a very common use case, the issue is occurring because you're using two different package managers to install node modules. The ideal solution would be to just use npm for everything, although yarn do make good arguments against it.

I think a better solution may be for me to manually check if yarn is installed and add that to the array. Other people will likely have this issue with yarn so it'll be nice if it works automatically. And it's unlikely to occur in any other scenarios so doesn't really warrant an extra option.

@SimenB
Copy link
Author

SimenB commented Dec 16, 2016

Yeah, that's fine as well 😄

@lukechilds
Copy link
Owner

lukechilds commented Dec 16, 2016

I'll take a look at that tomorrow :)

You can track progress here: #16

@SimenB
Copy link
Author

SimenB commented Dec 16, 2016

No rush, thank you!

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