-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Global packages no longer work after node.js update with homebrew #2064
Comments
The same issue exists for node installed via nvm:
However adding this prefix flag symlinks the installed module into
Checking the symlink shows me that the module was actually installed here:
Found this solution here #1877 |
Thank you, however I personally think that your fix is more of a work around and not a permanent solution. I was looking to start a discussion of how this could be handled within yarn or brew so that yarn global packages are not effected on a node.js version change. On the other hand npm global packages function fine after a |
I had the same issue several times too. |
same issue here, is there a permanent solution? |
Got the same issue here. |
same issue |
Yarn adds a symlink of the executables to node's When I updated to node 7.4.0 from 7.2.1 the symlinks weren't added to the new version. I'm guessing you're seeing the same thing. The problem is, there's no way of using yarn right now to fix this. You could write a script that does something along the lines of:
I'll write an npm package later that does all this. |
Hey guys, I've written an npm package that should fix your yarn-installed global packages. $ npm install -g fix-yarn-global-packages
$ fix-yarn-global-packages That should fix all your global packages. Let me know if it doesn't work for you. |
Thanks @bradley-curran but I personally prefer to just add |
I've been doing some more digging and it seems the issue is that yarn doesn't read all npm config files that npm itself uses. Yarn should read all files defined in npm's npmrc documentation Currently yarn only reads config files from:
The config files that also need to be read include:
The problem is that these files can't be found easily using the existing architecture afaict. Quick Fix
The Real FixRead all configuration files, ideally by delegating to |
@bradley-curran thanks so much for looking into this, from now on I'll use the npmrc file. (I didn't know that the npmrc existed until now). Just a small word of warning that npm will also install global packages to the prefix set in in the npmrc and no longer in |
Agree it should not install into /usr/local/Cellar/node/version . As a temporary fix, it's now possible to Although this prefix should be set by default on yarn installation. |
Similar issue: #2639 |
Thanks @mkutny, is the |
@publicarray , I just did it according to the doc which says It seems that in this particular case it doesn't matter but for options which could be set for either local or global scope, it does. |
@mkutny thanks, I should have read the docs 📖 |
Can't this be fixed by having the homebrew formula do
as a post-install? |
You can, if you're willing to assume that the prefix is /usr/local on all machines, which I'm not sure can be assumed. |
Good point. Within the context of Homebrew formulae, I do believe the global Homebrew-prefix is available in a variable. It would be better to use that. |
Please stop advocating the |
@vdh , it's not about which solution "is a whole lot easier". It's all about what is the right thing to do. If you read the thread carefully there are currently several issues with global packages:
Binaries in |
@vdh the solution to dead symlinks in /usr/local/bin is to fix the problem that causes dead symlinks in there, not to preserve broken behaviour in yarn. Like @mkutny says, there are several issues with |
I'm not sure if this is related or not, but with zsh, I have an export on startup with the path from |
@partounian I recommend you open a new issue because your problem is unrelated. Is it possible that you are calling yarn before you initialised the $PATH? e.g. ~/.zshrc: yarn global bin
export PATH=$(brew --prefix)/bin:$PATH # run this first |
Adding The issue is that Yarn symlinks the executables into the wrong directory (the Node.js directory rather than somewhere reasonable). It doesn't really make sense to use the Node.js directory for these scripts, and on many systems that directory is not even writable by regular users. I fixed this for Windows in #3233 but we still need fixes for other operating systems. #3458 seems reasonable as long as the user has write access to |
TL;DR Use a default directory for Windows/macOS. Ask user to set directory on Linux/others. Windows and macOS For Windows and macOS, we can use On macOS, Yarn global binaries will work without extending the Linux et al.
Or we can show an interactive
The current behaviour has been copied from npm which was written about 5 years ago and has seen no updates: https://github.com/npm/npm/blob/771c66884a0a1851cffb3bf132828f6ccef1c09c/lib/config/defaults.js#L92-L105 |
Shall we honor this setting too?
I think this is a really subpar experience for Windows users. Node puts itself into the path along with npm right, why can't we use those directories directly? |
The Windows installer (and Chocolatey package) automatically update the path, so this is mostly a non-issue.
On most systems, it would require you to run Yarn as administrator, as Node is normally installed at C:\Program Files\nodejs and Node.js doesn't expose the Win32 API for requesting elevation (getting admin rights after the app has started, like "sudo") |
@Daniel15 oh, okay so this clears my Windows-side questions :) |
Well, with the exception of, when/if we install |
I think it'd depend on where Node.js is installed and what the permissions are on that directory. |
We could probably update Yarn so that it edits the path on first run. However I don't know if Node.js exposes an API for that. It's got extremely limited ffi capabilities without dealing with complex native modules. |
Did some reading on https://docs.npmjs.com/files/folders#prefix-configuration and looks like the approach in the diff is correct. Just concerned about not using the |
**Sumary** Refs #2064. Uses `%LOCALAPPDATA%\Yarn\bin` and `/usr/local/bin` on POSIX systems if it's writeable, falling back to `~/.yarn/bin` if it is not. **Test plan** N/A. Should add automated tests.
|
I had the same issue in ubuntu after upgrade node version with |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When node and yarn are installed with homebrew
yarn global bin
returns a path that is tied to the a specific version of node. If node is updated with brew the symlinks are no longer valid, i.e global packages with binaries need to be reinstalled.~ ❯ yarn global bin /usr/local/Cellar/node/7.2.0/bin
Related issue: Homebrew/homebrew-core#7283
If the current behavior is a bug, please provide the steps to reproduce.
I've used brew reinstall to emulate an update, I'm not sure how different it is to
brew upgrade node
.What is the expected behavior?
~ ❯ bower --version 1.8.0
Please mention your node.js, yarn and operating system version.
The text was updated successfully, but these errors were encountered: