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

`brew link node` required for Yarn install #1505

Open
sdaitzman opened this Issue Oct 27, 2016 · 36 comments

Comments

Projects
None yet
@sdaitzman
Copy link

sdaitzman commented Oct 27, 2016

Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Installing Yarn using the Homebrew formula requires that node be installed and linked using Homebrew, which is a conflict for people (such as me) who update and switch between node binaries with https://github.com/tj/n
If the current behavior is a bug, please provide the steps to reproduce.
Run $ brew install yarn
What is the expected behavior?
Provide a warning if node.js is not linked using Homebrew, without erroring
Please mention your node.js, yarn and operating system version.
node v6.7.0, yarn not installed, macOS 10.12.1 (16B2555)

@elaijuh

This comment has been minimized.

Copy link

elaijuh commented Nov 2, 2016

same for me, using nvm is ok

@sdaitzman

This comment has been minimized.

Copy link

sdaitzman commented Nov 2, 2016

@elaijuh this is because nvm (as of last time I looked at their code) relies on hacky shell modifications to switch node versions, meaning it should never be used in production and sometimes breaks modules.

My temporary fix is removing n's installed node, forcing Homebrew to link its node, installing yarn with Homebrew, and then overwriting Homebrew's node link with n's node. (Or just installing with npm, I assume 😋 )

@elaijuh

This comment has been minimized.

Copy link

elaijuh commented Nov 3, 2016

@sdaitzman i think i will go npm way before some neat solution comes out, thanks.

@wavded

This comment has been minimized.

Copy link

wavded commented Nov 21, 2016

Same issue. I cannot run node6-lts node and upgrade yarn at the same time because of this error.

@wavded

This comment has been minimized.

Copy link

wavded commented Nov 21, 2016

To get around this issue for now I do:

brew unlink node6-lts
brew link node
brew upgrade # to update yarn
brew unlink node
brew link node6-lts
@mgol

This comment has been minimized.

Copy link

mgol commented Dec 12, 2016

@sdaitzman nvm is not hacky; most of what it does is just to prepend the path to currently chosen Node.js binaries to PATH and that's it. I'd say solutions like rbenv or pyenv that install shims that dispatch binaries to a proper Ruby/Python version dynamically are what's hacky, not what nvm does. Changing PATH is a pretty standard thing to do.

@altern8tif

This comment has been minimized.

Copy link

altern8tif commented Jan 17, 2017

So should there be/is there gonna be a fix for this? Or are n users gonna have to mess around with brew to upgrade yarn?

@OmerHerera

This comment has been minimized.

Copy link

OmerHerera commented Jan 18, 2017

I have the same issue here.

Some how I succeed installing yarn v0.18.1 using brew but I got stuck now with this version, I want to upgrade and I got this message: Error: You must brew link node before yarn can be installed

I must mention that I'm using also using n for managing my node version, this is a must because I'm working in different projects with different node versions.
I really don't wan to stop using n and also don't want to start removing my node version I installed.

Is there a solution for us?
Thanks

@phil-r

This comment has been minimized.

Copy link

phil-r commented Jan 18, 2017

Same problem as @OmerHerera but I'm using nvm

➜  node -v
v6.9.2
➜  brew -v
Homebrew 1.1.7-60-g9f183be35
Homebrew/homebrew-core (git revision 98466; last commit 2017-01-18)
➜  yarn --version
0.18.1

macOS 10.12.2

@OmerHerera

This comment has been minimized.

Copy link

OmerHerera commented Jan 23, 2017

I succeed upgrading running:
curl -o- -L https://yarnpkg.com/install.sh | bash

@phil-r

This comment has been minimized.

Copy link

phil-r commented Jan 23, 2017

@OmerHerera I did that, but yarn --version is still 0.18.1

Edit: Completely uninstalled and reinstalled using this method and now it's updated, but this is kinda kills the purpose of brew

@OmerHerera

This comment has been minimized.

Copy link

OmerHerera commented Jan 23, 2017

Somehow for me it succeed
yarn --version
0.19.1

Sorry to hear that :-(

@iddan

This comment has been minimized.

Copy link

iddan commented Jan 24, 2017

Should make more versions of node installs (i.e node@6) to be valid for yarn

@sgarcia-dev

This comment has been minimized.

Copy link

sgarcia-dev commented Jan 31, 2017

Having the same issues mentioned, however, I tried to uninstall yarn (previously in v0.18.1) in hopes installing it would upgrade it, but now I can't even install it back into my machine, and are constantly getting:

You must 'brew link node' before yarn can be installed

So for now, there is no way to get yarn to run again?
Running node v6.9.4, with Homebrew v1.1.9 on Mac OS Capitan

@mgol

This comment has been minimized.

Copy link

mgol commented Jan 31, 2017

@sgarcia-dev

You must 'brew link node' before yarn can be installed

So for now, there is no way to get yarn to run again?

Why haven't you just done what it told you to do?

@sgarcia-dev

This comment has been minimized.

Copy link

sgarcia-dev commented Jan 31, 2017

@mgol

Why haven't you just done what it told you to do?

Because I get an error while trying to run both brew link node and brew unlink node. The first error I get is target already exists, and while trying to unlink it I get a simple message saying no symlinks were removed.

@mgol

This comment has been minimized.

Copy link

mgol commented Jan 31, 2017

I see. Try brew link --overwrite node.

@sgarcia-dev

This comment has been minimized.

Copy link

sgarcia-dev commented Jan 31, 2017

I see. Try brew link --overwrite node.

@mgol I did, it returned;

Linking /user/local/Cellar/node/7.4.0...
Error: Could not symlink share/doc/node/gdbinit
/usr/local/share/doc/node is not writable

And running brew install yarn still returns the same error :S

@mgol

This comment has been minimized.

Copy link

mgol commented Jan 31, 2017

@sgarcia-dev You have permissions issues, this is unrelated to Yarn but to an incorrectly setup Homebrew. Ping me on Gitter if you want help with that.

@jschank

This comment has been minimized.

Copy link

jschank commented Feb 4, 2017

I also have this problem (yarn installed with brew, and using nvm)
Is it possible for brew to symlink to the nvm version of node?

@ghost

This comment has been minimized.

Copy link

ghost commented Feb 15, 2017

@mgol it works

@ConAntonakos

This comment has been minimized.

Copy link
Contributor

ConAntonakos commented Feb 15, 2017

Just ran into this issue. I'm working off of node@6 rather than node which pulls v7.x at the moment. I have node v6.x installed instead. It seems like yarn is expecting only brew link node which equates to the latest version. Is there a way around this, am I doing something wrong, or maybe this requires an update? 😄

@Judahmeek

This comment has been minimized.

Copy link

Judahmeek commented Feb 15, 2017

Removing yarn from brew and reinstalling it through the curl script is likely the simplest solution. Temporarily modifying file permissions as necessary is another possibility. Long-term, it looks like there needs to be some kind of interactive dependency injection.

@Suzukaze-Yoru

This comment has been minimized.

Copy link

Suzukaze-Yoru commented Feb 20, 2017

I found out what was the problem. When install yarn use brew, brew will install it's deps node.
So, the relationship between yarn and node is dependent.

Then I remove node in brew just like rm /usr/local/Cellar/node, I can reinstall yarn one more time.

@mgol

This comment has been minimized.

Copy link

mgol commented Feb 20, 2017

@x4storm don't remove Homebrew-related stuff manually, you'll leave it in an unstable state and you're on your own then; anything may break.

It's better to just ignore that brew install yarn also installs node; you can use a different Node version, e.g. using nvm.

@carloscalla

This comment has been minimized.

Copy link

carloscalla commented Feb 26, 2017

@mgol I was just recommended by a friend to use yarn. I look into its installation steps and it says that brew install yarn will install yarn and nodejs if it is not installed. Since this installation is by homebrew I guess homebrew will check if node is installed by homebrew or if it is in /usr/local. I installed node using n with n-install (great choice to install n). I don't know if running brew instlal yarn will install correctly since n installs node versions inside n's folder. Any recommendation here? I am afraid I run brew install yarn and it installs yarn and a system wide node that may conflict with my n node.

@SenHeng

This comment has been minimized.

Copy link

SenHeng commented Feb 26, 2017

@carloscalla

It seems like the first attempt to install yarn doesn't cause any problems. It's the subsequent attempts to update yarn where brew gets all hissy about node not being where it should be. So until brew finds a way to play nice with nvm (or n), it's probably easier to install yarn using npm.

@carloscalla

This comment has been minimized.

Copy link

carloscalla commented Feb 27, 2017

@SenHeng Hi, I read that in their installation page but they don't recommend it and I am not sure how that would impact on yarn's performance :(

@SenHeng

This comment has been minimized.

Copy link

SenHeng commented Feb 27, 2017

@carloscalla

It's not recommended because they wanted to avoid the 'using a package manager to install a package manager' joke. It was mentioned in one of the issues, you might be able to find it. Performance wise it shouldn't affect anything.

@carloscalla

This comment has been minimized.

Copy link

carloscalla commented Feb 27, 2017

@SenHeng Thank you very much, your comments were very helpful :D

@mgol

This comment has been minimized.

Copy link

mgol commented Feb 27, 2017

@carloscalla the main problem is that you'll have to suffer npm bugs while installing yarn (it did happen to me a few times to get a broken package in the past).

@djmadeira

This comment has been minimized.

Copy link

djmadeira commented Feb 28, 2017

You can also run brew uninstall yarn && brew install yarn --ignore-dependencies. For some reason, brew upgrade doesn't support the --ignore-dependencies flag.

Edit: this works with nvm, haven't tried n.

@roman-bystrimovich

This comment has been minimized.

Copy link

roman-bystrimovich commented Mar 2, 2017

Same way as previous but using mac port:

Edit local port:
sudo port edit yarn
Comment lines with dependencies (add # in the beginning). In my case:
depends_run path:bin/node:nodejs6
and
depends_run-replace path:bin/node:nodejs6 path:bin/node:nodejs4
Install yarn:
sudo port install yarn

Works with nvm. Updating with sudo port upgrade outdated is not tested

@alisyed-drupalmaze

This comment has been minimized.

Copy link

alisyed-drupalmaze commented Mar 18, 2017

I run into same kind of issue but solve problem via node upgrade to new version of
node v7. & yarn 0.21 using brew.

step 1: brew install node
Warning: node-7.7.3 already installed, it's just not linked.

step 2: well it's easy to link with brew:
brew link --overwrite node

step 3: Now check if yarn install and link
if not install & link then type these command:

brew install yarn
yarn --version 0.21.3
brew link --overwrite yarn

@jonscottclark

This comment has been minimized.

Copy link

jonscottclark commented Apr 6, 2017

@djmadeira Great solution - and non-destructive to my current node setup. Thanks!

@bestander bestander removed the needs triage label May 23, 2017

@artdent

This comment has been minimized.

Copy link

artdent commented Sep 7, 2017

This issue can probably be closed now that, per Homebrew/homebrew-core#16021 and the new instructions on https://yarnpkg.com/en/docs/install, you can use brew install yarn --without-node to install yarn without affecting your existing node installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment