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 · 122 comments
Closed

yarn global add doesn't install binaries properly #648

fahrradflucht opened this issue Oct 11, 2016 · 122 comments

Comments

@fahrradflucht
Copy link

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 [email protected]: The engine "rhino" appears to be invalid.
warning [email protected]: The engine "rhino" appears to be invalid.
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed [email protected] 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 [email protected]: The engine "rhino" appears to be invalid.
warning [email protected]: The engine "rhino" appears to be invalid.
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed [email protected] 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

The same behaviour here, on the same system.

@fahrradflucht
Copy link
Author

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 commented Oct 12, 2016

Also got this on Ubuntu 15.10 system

@wokalski
Copy link

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

@fahrradflucht
Copy link
Author

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 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 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

@fahrradflucht sorry! Fixed it.

@fahrradflucht
Copy link
Author

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

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

@kaihendry Because Yarn was installed by Homebrew

@andyyou
Copy link

andyyou commented Nov 3, 2016

Same issues on macOS

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

lekhnath commented Feb 5, 2017

exact same issue as @c0bra stated.

@gaearon
Copy link
Contributor

gaearon commented Feb 8, 2017

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

@adambiggs
Copy link

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

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 "[email protected]" with binaries:
      - ember
warning No license field
Done in 3.81s.
$ cd $(yarn global bin)
$ ls
tern@  yarn@  yarnpkg@

@shinzui
Copy link

shinzui commented Feb 23, 2017

Still broken in 0.20.3 installed through homebrew on macOS.

@pdesjardins90
Copy link

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)

@DanielRuf
Copy link
Contributor

Same here.

@mikemaccana
Copy link
Contributor

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

i see ppl add path to .bashrc

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

@telami
Copy link

telami commented Oct 20, 2018

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

NB,nice,666

@gnemtsov
Copy link

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 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

Does #648 (comment) not help?

@karansapolia
Copy link

karansapolia commented Jan 23, 2019

Does #648 (comment) not help?

My bad. That solves the issue.

@amartincolby
Copy link

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

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

Works for me on Ubuntu.

@rantirules
Copy link

sudo yarn global add ignite-cli
Worked for me

@hoefling
Copy link

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 "[email protected]" 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

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

@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

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

@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.

@vituchon
Copy link

this worked for me yarn config set prefix ~/.local, i guess, after all, you only need to configure yarn app to write into a part of the file system that is accessible for the current user.

@Dragon1573

This comment has been minimized.

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Oct 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests