-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Change global prefix directory to /usr/local
on OS X
#3458
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
Conversation
I believe this PR would also fix: #2064 |
Looping in @Daniel15 as I completely lost faith in trying to understand all those prefixes needed for every OS |
I'm not very familiar with Mac OS, but the issue on Linux would be that regular users normally don't have write access to It might be easier to just always use a user directory like |
To me it seems like a safe enough change for Mac OS, let's merge it. @KishanBagaria, you have expressed a few good ideas about paths in Linux. |
On Google corporate OS X machines FWIW I've been manually adding my homebrew'd For me, it'd be perfect to install the global links into |
Thanks for feedback @paulirish. @KishanBagaria would you give it another try with @Daniel15's feedback? |
This reverts commit edfc370.
@paulirish That must needlessly require sudo for a lot of install scripts. Maybe you should drop the suggestion of making Until the next Yarn release, you can simply run |
This sets the global prefix in a homebrew installation to a configurable package.json variable, which can be replaced by homebrew during formula installation with the actual value of HOMEBREW_PREFIX (similar to how installationMethod is already replaced there). This commit is a improved version of yarnpkg#3458 with added support for custom homebrew prefixes, which should address the issue from: yarnpkg#3458 (comment) Refs: yarnpkg#1194 Refs: Homebrew/homebrew-core#16083
This sets the global prefix in a homebrew installation to a configurable package.json variable, which can be replaced by homebrew during formula installation with the actual value of HOMEBREW_PREFIX (similar to how installationMethod is already replaced there). This commit is an improved version of yarnpkg#3458 with added support for custom homebrew prefixes, which should address the issue from: yarnpkg#3458 (comment) Refs: yarnpkg#1194 Refs: Homebrew/homebrew-core#16083
This sets the global prefix in a homebrew installation to a configurable package.json variable, which can be replaced by homebrew during formula installation with the actual value of HOMEBREW_PREFIX (similar to how installationMethod is already replaced there). This commit is an improved version of yarnpkg#3458 with added support for custom homebrew prefixes, which should address the issue from: yarnpkg#3458 (comment) Refs: yarnpkg#1194 Refs: Homebrew/homebrew-core#16083
When node is installed from Homebrew, node exists at
/usr/local/Cellar/node/7.10.0/bin/node
So yarn's global bin directory (
yarn global bin
) becomes:/usr/local/Cellar/node/7.10.0/bin
This creates two problems:
/usr/local/Cellar/node/(version)/bin
is not present inPATH
by default. Users have to modify their profile to extendPATH
withyarn global bin
.When node is upgraded, all linked global binaries become inaccessible since
yarn global bin
automatically gets changed to/usr/local/Cellar/node/(latest-version)
from/usr/local/Cellar/node/(old-version)
. The global bin directory should remain constant on upgrades.The fix is to simply use
/usr/local/bin
as the default global bin directory in OS X installations. NPM (npm --global prefix
) also uses that directory (at least when installed from Homebrew).This should also fix #1194.
Alternatives
Instead of all OS X installations, this change can be applied only to installations where node is installed from Homebrew, by checking if
process.execPath
begins with/usr/local/Cellar
. Although, this issue would still be present with nvm or some other node-installer.Instead of modifying yarn, a patch could be made in the Yarn formula to automatically run
yarn config set prefix /usr/local
. (EDIT: It's not possible atm: Yarn global packages with brew's node.js no longer work on node update. Homebrew/homebrew-core#7283 (comment)) Other node-installers like nvm will also require similar changes.In the
getGlobalPrefix
function, instead ofthis could be used: