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

yarn global add doesn't install binaries properly #648

Closed
fahrradflucht opened this Issue Oct 11, 2016 · 112 comments

Comments

Projects
None yet
@fahrradflucht
Copy link

fahrradflucht commented Oct 11, 2016

Do you want to request a feature or report a bug?
bug

What is the current behavior?

➜  ~  yarn global add create-react-app
yarn global v0.15.1
warning No license field
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
warning lodash@2.4.2: The engine "rhino" appears to be invalid.
warning benchmark@1.0.0: The engine "rhino" appears to be invalid.
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
success Installed create-react-app@0.5.0 with binaries:
      - create-react-app
✨  Done in 8.43s.
➜  ~  which create-react-app
create-react-app not found

What is the expected behavior?

➜  ~  yarn global add create-react-app
yarn global v0.15.1
warning No license field
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
warning lodash@2.4.2: The engine "rhino" appears to be invalid.
warning benchmark@1.0.0: The engine "rhino" appears to be invalid.
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
success Installed create-react-app@0.5.0 with binaries:
      - create-react-app
✨  Done in 8.43s.
➜  ~  which create-react-app
/usr/local/bin/create-react-app

Please mention your node.js, yarn and operating system version.

➜  ~  system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.12 (16A323)
      Kernel Version: Darwin 16.0.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled

➜  ~ node --version
v6.7.0
➜  ~  yarn --version
0.15.1
@osenvosem

This comment has been minimized.

Copy link

osenvosem commented Oct 11, 2016

The same behaviour here, on the same system.

@fahrradflucht

This comment has been minimized.

Copy link

fahrradflucht commented Oct 11, 2016

Just a note to clarify that this isn't unique to create-react-app. mean-cli for example surfaces the same issue.

@metame

This comment has been minimized.

Copy link

metame commented Oct 12, 2016

Also got this on Ubuntu 15.10 system

@wokalski

This comment has been minimized.

Copy link

wokalski commented Oct 12, 2016

Run yarn global bin and add it to your $PATH.

@fahrradflucht

This comment has been minimized.

Copy link

fahrradflucht commented Oct 12, 2016

This fixes it. But this isn't documented in any way here: https://yarnpkg.com/en/docs/cli/global
(I mean yes yarn global bin is documented but the example doesn't suggest that adding it to your PATH is necessary)

On my machine this returns /usr/local/Cellar/node/6.7.0/bin. Does this mean that all my global binaries are tied to this node version and if I update I have to reinstall them? That seems messy doesn't it?

Another thing I noticed is that "$(yarn global bin)" returns ^[[2K^[[1G/usr/local/Cellar/node/6.7.0/bin. Am I doing something wrong when I try adding export="${PATH}:$(yarn global bin)" to my .zshrc?

@wokalski

This comment has been minimized.

Copy link

wokalski commented Oct 12, 2016

It's not documented AFAIK. It should be. Feel free to submit a PR.
Read this to understand why global path is version specific.

@fahrradflucht

This comment has been minimized.

Copy link

fahrradflucht commented Oct 12, 2016

@wokalski are you sure you referenced the right issue? I don't even get why this is related...

@wokalski

This comment has been minimized.

Copy link

wokalski commented Oct 12, 2016

@fahrradflucht sorry! Fixed it.

@fahrradflucht

This comment has been minimized.

Copy link

fahrradflucht commented Oct 12, 2016

Okay got it!

Then I'm left with this question:

Another thing I noticed is that "$(yarn global bin)" returns ^[[2K^[[1G/usr/local/Cellar/node/6.7.0/bin. Am I doing something wrong when I try adding export="${PATH}:$(yarn global bin)" to my .zshrc?

I would file a new issue if I was more sure that I didn't made a dumb mistake 😁

@kitsunde

This comment has been minimized.

Copy link

kitsunde commented Oct 12, 2016

@fahrradflucht It's not just you I have the same issue on macOS using plain old bash.

export PATH="/usr/local/Cellar/node/6.3.1/bin:$PATH"

works

export PATH="$(yarn global bin):$PATH"

Does not. I've opened an issue; #851

@kaihendry

This comment has been minimized.

Copy link

kaihendry commented Oct 15, 2016

yarn global bin is /usr/bin on my system. I want it to be /usr/local/bin to save me from perm headaches.

Now that I'm thinking about it... why doesn't yarn global bin return ~/.yarn-cache/.global/node_modules/.bin/?

@smoothdvd

This comment has been minimized.

Copy link

smoothdvd commented Oct 18, 2016

@kaihendry Because Yarn was installed by Homebrew

@andyyou

This comment has been minimized.

Copy link

andyyou commented Nov 3, 2016

Same issues on macOS

@c0bra

This comment has been minimized.

Copy link

c0bra commented Jan 23, 2017

Yarn doesn't seem to be installing binaries in to $(yarn global bin), which since I'm using nvm on OSX is /Users/username/.nvm/versions/node/v6.9.2/bin

After doing yarn global add nodemon it's nowhere to be found, and nothing in a verbose install seems to show it putting any files in a bin directory.

UPDATE

yarn global remove nodemon and yarn global add nodemon fixed it and place it in $(yarn global bin) properly. Still nothing in the verbose log however...

@lekhnath

This comment has been minimized.

Copy link

lekhnath commented Feb 5, 2017

exact same issue as @c0bra stated.

@gaearon

This comment has been minimized.

Copy link
Contributor

gaearon commented Feb 8, 2017

I see a report this was fixed in 0.20 RC. Can somebody verify please?

@adambiggs

This comment has been minimized.

Copy link

adambiggs commented Feb 9, 2017

I just ran into this issue with v0.20.0 but resolved it by removing and re-adding the package as @c0bra mentioned.

@erizocosmico

This comment has been minimized.

Copy link

erizocosmico commented Feb 17, 2017

Still not working for me in v0.20.3:

$ cd $(yarn global bin)
$ ls 
tern@  yarn@  yarnpkg@
$ yarn global add ember-cli
yarn global v0.20.3
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "ember-cli@2.11.1" with binaries:
      - ember
warning No license field
Done in 3.81s.
$ cd $(yarn global bin)
$ ls
tern@  yarn@  yarnpkg@
@shinzui

This comment has been minimized.

Copy link

shinzui commented Feb 23, 2017

Still broken in 0.20.3 installed through homebrew on macOS.

@pdesjardins90

This comment has been minimized.

Copy link

pdesjardins90 commented Feb 23, 2017

Had the same problem today (homebrew installation, yarn v0.20.3). Figured that I forgot to export the bin folder to my PATH before installing global packages. I exported it using :

export PATH="$(yarn global bin):$PATH"

and then removing and re-adding global packages correctly linked the binaries. (Thanks @c0bra)

@jthegedus

This comment has been minimized.

Copy link

jthegedus commented Mar 3, 2018

@DavidNorena The docs do actually mention this, but since this is a setup step it resides in the installation page. Even then, it's still not made super clear as in the Linux Tab on the install page https://yarnpkg.com/en/docs/install the Path Setup section is after the instructions for each Linux distro.I imagine most people use Ubuntu (which is first in the list) and so never scroll down the page and never see the additional setup step.

[Edit]: @DavidNorena I agree the docs are not ideal, as the right-hand side quick links are for other pages and not a summary of the headings on this page. I frequently forget to do this step and I set up a lot of machines! I would PR an update if I had the time to learn the current doc site setup. The discussion for the correct solution is for another issue though.

@DavidNorena

This comment has been minimized.

Copy link

DavidNorena commented Mar 3, 2018

But still it's not clear, I didn't know there was a PATH SETUP section, I just followed the steps for my Linux Box version, but there was not indication whether to go to the page end or not.

Thank you @jthegedus and the next time I will look all sections in the docs, no one knowns. :D

@SiriusBits

This comment has been minimized.

Copy link

SiriusBits commented Mar 24, 2018

Having repeatedly dealt with this issue, I finally reached a solution for my scenario that I thought I'd share in case it helps someone.

For reference I am on MacOS (Sierra), using zsh (and oh-my-zsh installed with Homebrew), NVM (0.33.8 installed via Homebrew --without-node)

Yarn's global bin was set to /users/MyUserName/usr/local/bin and zsh wouldn't recognize Yarn packages installed globally since this wasn't in my PATH. While I could have added my users path, I decided to instead set my Yarn global bin to use the /usr/local/bin, which was already in PATH which worked and won't break when switching versions of Node with NVM.

@Nexxado

This comment has been minimized.

Copy link

Nexxado commented Mar 30, 2018

I'm having a similar issue specifically with a global installation of typescript.

Executing yarn global bin outputs /usr/local/bin and all other global packages have their binaries added (symlinked) to /usr/local/bin as expected.

When i execute yarn global add typescript, the output is:

[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
success Installed "typescript@2.8.1" with binaries:
      - tsc
      - tsserver
✨  Done in 4.89s.

Trying to execute tsc or tsserver commands results in command not found: tsc.
Looking under /usr/local/bin shows neither tsc nor tsserver binaries.

  • This works fine when using npm (tested v5.6.0)
  • I'm using yarn v1.5.1, macOS 10.13.3
@SiriusBits

This comment has been minimized.

Copy link

SiriusBits commented Mar 30, 2018

@Nexxado I followed your steps as you described, and got the same messages from Yarn. However, the packages were installed as you'd expect and appear in /usr/local/bin. Typing tsc -v outputs Version 2.8.1.
I am using nvm and node version 9.6.1 with npm 5.6.0.

Had you tried to install this previously and if so, were you able to verify it was removed? I had trouble with certain packages I had installed with earlier versions of npm or homebrew that interfered with global installs via Yarn.

@Nexxado

This comment has been minimized.

Copy link

Nexxado commented Mar 30, 2018

@SiriusBits

Had you tried to install this previously and if so, were you able to verify it was removed? I had trouble with certain packages I had installed with earlier versions of npm or homebrew that interfered with global installs via Yarn.

That's possible, I don't remember if i did.
I'm using nvm with node v8.9.3 and npm 5.6.0.

Were you able to fix those "certain packages" you were talking about?

Thanks in advance :)

@SiriusBits

This comment has been minimized.

Copy link

SiriusBits commented Mar 30, 2018

@Nexxado I did. I had Gulp CLI that was installed with npm and couldn't get the global install with Yarn to work. Once I removed it and re-installed with Yarn, it worked.

@rod-stuchi

This comment has been minimized.

Copy link

rod-stuchi commented Apr 18, 2018

I installed node with asdf-nodejs, and have the same issue with yarn 1.6.0 in macOS

added this line in .zshrc file solved the problem.

export PATH=/Users/rods/.asdf/installs/nodejs/8.9.4/.npm/bin:$PATH
@navdeepio

This comment has been minimized.

Copy link

navdeepio commented May 2, 2018

Why is this issue closed? I'm facing the same problem on linux

@BYK

This comment has been minimized.

Copy link
Member

BYK commented May 3, 2018

@jthegedus @DavidNorena would you be interested in improving the docs so others can benefit?

@jthegedus

This comment has been minimized.

Copy link

jthegedus commented May 6, 2018

@BYK I'll link this issue in the PR I create this week πŸ‘

@Marmeladenbrot

This comment has been minimized.

Copy link

Marmeladenbrot commented Jul 10, 2018

Facing the same issue on Window 10.

yarn global dir and yarn global bin are both in the %PATH% but no binaries are installed.

removing and re-adding a package didn't help.

Yarn 1.7.0
Node.js 10.3.0

wishdasher added a commit to Khan/wonder-blocks that referenced this issue Jul 17, 2018

Fix build to find codecov (#211)
The command `yarn run build:coverage && codecov` started failing with message `codecov: command not found` in the travis builds. Build #1663 passed but build #1666 failed. We didn't change our config files between those builds, so perhaps something changed with travis or yarn.

This [issue](yarnpkg/yarn#648) indicates that `global add` didn't put the binary in the expected location, so we append `yarn global bin` to `PATH`.
@DanielRuf

This comment has been minimized.

Copy link

DanielRuf commented Jul 18, 2018

Same here.

@mikemaccana

This comment has been minimized.

Copy link
Contributor

mikemaccana commented Oct 1, 2018

Still broken in 1.10.1:

$ yarn global add typescript
yarn global v1.10.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 0.47s.

$ yarn global bin
C:\Users\mikem\AppData\Local\Yarn\bin

$ yarn global list
yarn global v1.10.1
Done in 0.14s.

@Pixelatex Pixelatex referenced this issue Oct 4, 2018

Closed

Cannot Create #789

@yurii-github

This comment has been minimized.

Copy link

yurii-github commented Oct 10, 2018

i see ppl add path to .bashrc

export PATH="$(yarn global bin):$PATH"

@telami

This comment has been minimized.

Copy link

telami commented Oct 20, 2018

export PATH="$(yarn global bin):$PATH"

NB,nice,666

@gnemtsov

This comment has been minimized.

Copy link

gnemtsov commented Nov 16, 2018

Same issue. Installed serve with yarn global add serve. After that starting serve fails: "serve: command not found". Updating PATH manually didn't help me. I installed serve with npm and now it works. Really strange that this problem is older than 2 years and is still unfixed.

@karansapolia

This comment has been minimized.

Copy link

karansapolia commented Jan 23, 2019

--Edit-- Solved. view #648
Still facing this problem. Installed yarn on Fedora, am using nvm to manage node versions. installed pug-cli in yarn globally. Running pug returned command not found. When installed pug-cli using npm, command runs.

@DanielRuf

This comment has been minimized.

Copy link

DanielRuf commented Jan 23, 2019

Does #648 (comment) not help?

@karansapolia

This comment has been minimized.

Copy link

karansapolia commented Jan 23, 2019

Does #648 (comment) not help?

My bad. That solves the issue.

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