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

yarn global add doesn't install binaries properly #648

Closed
fahrradflucht opened this issue Oct 11, 2016 · 120 comments
Closed

yarn global add doesn't install binaries properly #648

fahrradflucht opened this issue Oct 11, 2016 · 120 comments

Comments

@fahrradflucht
Copy link

@fahrradflucht 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
Copy link

@osenvosem osenvosem commented Oct 11, 2016

The same behaviour here, on the same system.

@fahrradflucht
Copy link
Author

@fahrradflucht 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
Copy link

@metame metame commented Oct 12, 2016

Also got this on Ubuntu 15.10 system

@wokalski
Copy link

@wokalski wokalski commented Oct 12, 2016

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

@fahrradflucht
Copy link
Author

@fahrradflucht 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
Copy link

@wokalski 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
Copy link
Author

@fahrradflucht fahrradflucht commented Oct 12, 2016

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

@wokalski
Copy link

@wokalski wokalski commented Oct 12, 2016

@fahrradflucht sorry! Fixed it.

@fahrradflucht
Copy link
Author

@fahrradflucht 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
Copy link

@kitsunde 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
Copy link

@kaihendry 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
Copy link

@smoothdvd smoothdvd commented Oct 18, 2016

@kaihendry Because Yarn was installed by Homebrew

@andyyou
Copy link

@andyyou andyyou commented Nov 3, 2016

Same issues on macOS

@c0bra
Copy link

@c0bra 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
Copy link

@lekhnath lekhnath commented Feb 5, 2017

exact same issue as @c0bra stated.

@gaearon
Copy link
Contributor

@gaearon gaearon commented Feb 8, 2017

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

@adambiggs
Copy link

@adambiggs 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
Copy link

@erizocosmico 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
Copy link

@shinzui shinzui commented Feb 23, 2017

Still broken in 0.20.3 installed through homebrew on macOS.

@pdesjardins90
Copy link

@pdesjardins90 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)

@Marmeladenbrot
Copy link

@Marmeladenbrot 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
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
Copy link
Contributor

@DanielRuf DanielRuf commented Jul 18, 2018

Same here.

@mikemaccana
Copy link
Contributor

@mikemaccana 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.
@yurii-github
Copy link

@yurii-github yurii-github commented Oct 10, 2018

i see ppl add path to .bashrc

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

@telami
Copy link

@telami telami commented Oct 20, 2018

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

NB,nice,666

@gnemtsov
Copy link

@gnemtsov 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
Copy link

@karansapolia 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
Copy link
Contributor

@DanielRuf DanielRuf commented Jan 23, 2019

Does #648 (comment) not help?

@karansapolia
Copy link

@karansapolia karansapolia commented Jan 23, 2019

Does #648 (comment) not help?

My bad. That solves the issue.

@amartincolby
Copy link

@amartincolby amartincolby commented Feb 26, 2019

I'm encountering the problem with NVM in a Docker container pulling a CentOS image. It's not an issue with the PATH being incorrect. I have scoured all over the image. My global installs are absolutely not being installed anywhere. It seems to fail at step 1/4, resolving packages.

@akopchinskiy
Copy link

@akopchinskiy akopchinskiy commented Sep 20, 2019

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

Works for me on Ubuntu.

@rantirules
Copy link

@rantirules rantirules commented Oct 19, 2019

sudo yarn global add ignite-cli
Worked for me

@hoefling
Copy link

@hoefling hoefling commented Mar 30, 2020

I can't write to /usr/local/bin due to missing sudo permissions:

$ yarn global add create-react-app
yarn global v1.21.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "create-react-app@3.4.1" with binaries:
      - create-react-app
error Cannot create "/usr/local/bin/create-react-app" due to insufficient permissions.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

/usr/local/bin is in PATH, ~/.config/yarn/global/node_modules/.bin/ is in PATH but neither yarn global nor yarn create are usable.

@DanielRuf
Copy link
Contributor

@DanielRuf DanielRuf commented Mar 30, 2020

Please try to update to yarn 1.22.4 @hoefling. Also this might be an issue with your setup. How did you install yarn?

@hoefling
Copy link

@hoefling hoefling commented Mar 30, 2020

@DanielRuf thank you for your response! I have 1.22.4 installed by the system administrator:

$ dnf info yarn
Yarn Repository                                                                                                                                                                    346 kB/s | 363 kB     00:01    
Installed Packages
Name         : yarn
Version      : 1.22.4
Release      : 1
Architecture : noarch
Size         : 5.1 M
Source       : yarn-1.22.4-1.src.rpm
Repository   : @System
From repo    : yarn
Summary      : Fast, reliable, and secure dependency management.
URL          : https://yarnpkg.com/
License      : BSD
Description  : Fast, reliable, and secure dependency management.
...

Looks like the package comes from yarn's own repo.

@DanielRuf
Copy link
Contributor

@DanielRuf DanielRuf commented Mar 30, 2020

yarn global v1.21.1

In your last response it was 1.21.1.
Does this still happen? I suggest opening a new issue and checking the other issues for solutions.

@hoefling
Copy link

@hoefling hoefling commented Mar 30, 2020

@DanielRuf you are right, I have tried setting up a local copy of yarn and downgrading to see whether it is a regression. Unfortunately, the error is also reproducible with 1.22.4. Will open a new issue if I don't find a solution myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet