Do you want to request a _feature_ or report a _bug_?
Bug
What is the current behavior?
Global packages installation doesn't work.
If the current behavior is a bug, please provide the steps to reproduce.
I installed yarn package via sudo dnf install yarn
~> echo $PATH
/usr/local/bin /usr/local/sbin /usr/bin /usr/sbin /home/joseluis/.composer/vendor/bin /home/joseluis/.composer/vendor/bin /home/joseluis/.node/bin /home/joseluis/.yarn/bin
~> yarn global add surge
yarn global v0.16.0
warning No license field
[1/4] Resolving packages...
warning surge > fstream-ignore > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed [email protected] with binaries:
- surge
error An unexpected error occured, please open a bug report with the information provided in "/home/joseluis/.yarn-config/global/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
~> tail -n 4 /home/joseluis/.yarn-config/global/yarn-error.log
Trace:
Error: EACCES: permission denied, unlink '/usr/bin/surge'
at Error (native)
What is the expected behavior?
Global binaries sould be executable.
Please mention your node.js, yarn and operating system version.
~> yarn version
yarn version v0.16.0
~> node -v
v4.6.0
~> npm -v
2.15.9
~> cat /etc/fedora-release
Fedora release 24 (Twenty Four)
~> fish -v
fish, version 2.3.1
Can confirm similar behavior in Windows 10, version 1607. I'm using node 4.5.0, along with yarn 0.16.0.
~> "yarn global add typescript" output
yarn global v0.16.0
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:
- tsc
- tsserver
error An unexpected error occured, please open a bug report with the information
provided in "C:\\Users\\USERNAME\\AppData\\Local\\Yarn\\config\\global\\yarn-e
rror.log".
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this c
ommand.
~> last 4 lines of yarn-error.log
Trace:
Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\tsc'
at Error (native)
Interesting... Two issues I see here:
/usr/bin, only /usr/local/bin. /usr/bin is only for packages managed by the system (apt-get, yum, dnf, etc.)/usr/bin or /usr/local/bin when the user doesn't have permission to write there. It should probably just use ~/.yarn/bin or something similar.I think running sudo yarn global add should work though.
Does "dnf install yarn" use our package repo? I'm not very familiar with Fedora, but it looks like dnf is an updated version of yum?
I think running sudo yarn global add should work though.I think running sudo yarn global add should work though.
Does not. I'm not using Fedora though, I'm using ArchLinux and installed yarn from the AUR and added $HOME/.yarn/bin to the $PATH. I also had to manually create these directories to stop my shell from complaining that such directory doesn't exist. The shell is fish 2.3.1, as @joseluisq's. Now I'm doing:
> sudo yarn global add create-react-app
yarn global v0.16.1
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed [email protected] with binaries:
- create-react-app
Done in 12.43s.
> which create-react-app
which: no create-react-app in (bin/:/home/fixnum/.rbenv/bin/:/home/fixnum/gocode/bin:/home/fixnum/bin/:/home/fixnum/.yarn/bin:/home/fixnum/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
Naturally, the first time I tried to install without sudo and I got the following error (which wasn't displayed in the terminal by the way, only in the log file):
Trace:
Error: EACCES: permission denied, symlink '../../home/fixnum/.yarn-config/global/node_modules/.bin/create-react-app' -> '/usr/bin/create-react-app'
at Error (native)
Why ../../ at the beginning?
node is 6.9.1, I don't have npm yet.
Yarn should not try putting files in
/usr/binor/usr/local/binwhen the user doesn't have permission to write there. It should probably just use~/.yarn/binor something similar.
I'm wondering why not simply use ~/.yarn/bin for all global binaries and never even try to use /usr/local/bin?
Relevant issue https://github.com/yarnpkg/yarn/issues/648
I get the same permission error In Window 10 when yarn global add try to link bins to
yarn global bin which is C:\Program Files\nodejs
I reported #1226
Interesting... Two issues I see here:
- Yarn should not be putting files in /usr/bin, only /usr/local/bin. /usr/bin is only for packages managed by the system (apt-get, yum, dnf, etc.)
- Yarn should not try putting files in /usr/bin or /usr/local/bin when the user doesn't have permission to write there. It should probably just use ~/.yarn/bin or something similar.
I think running sudo yarn global add should work though.
Does "dnf install yarn" use our package repo? I'm not very familiar with Fedora, but it looks like dnf is an updated version of yum?
@Daniel15
Yep, dnf is the next version of yum it operates similarly. (Compatible with rpm packages too)
In any case, yarn should allow to set a custom binary path somehow. Maybe similar to npm:
~> cat ~/.npmrc
prefix = /home/my-local-user/.node/bin
Adding export PREFIX=~/.local to my .bash_profile (followed by source ~/.bash_profile) fixed it for me. Yarn now links binaries to ~/.local/bin, which is in my PATH.
I briefly went over the issues and found some of the related ones: https://github.com/yarnpkg/yarn/issues/1389, https://github.com/yarnpkg/yarn/issues/1388, https://github.com/yarnpkg/yarn/issues/1321, https://github.com/yarnpkg/yarn/issues/1226, https://github.com/yarnpkg/yarn/issues/1194, https://github.com/yarnpkg/yarn/issues/1151, https://github.com/yarnpkg/yarn/issues/1060, https://github.com/yarnpkg/yarn/issues/1029, https://github.com/yarnpkg/yarn/issues/927#issuecomment-253422378, https://github.com/yarnpkg/yarn/issues/630.
Similar issue on macOS, I use nvm for my node environment. When I install a new version of node then yarn global does't install pkg correctly
btw I use brew to install yarn.
The information as follow
System Software Overview:
System Version: macOS 10.12.1 (16B2555)
Kernel Version: Darwin 16.1.0
Boot Volume: Macintosh HD
Boot Mode: Normal

Similar issue. I use macOS. I use homebrew to install node and yarn.
$ yarn global add vue-cli
yarn global v0.16.1
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:
- vue
- vue-init
- vue-list
โจ Done in 1.75s.
$ vue
zsh: command not found: vue
$ yarn global bin
/usr/local/Cellar/node/7.1.0/bin
$ /usr/local/Cellar/node/7.1.0/bin/vue
Usage: vue <command> [options]
Commands:
init generate a new project from a template
list list available official templates
help [cmd] display help for [cmd]
Options:
-h, --help output usage information
-V, --version output the version number
I could solve this problem temporary by adding /usr/local/Cellar/node/7.1.0/bin into $PATH. But anytime homebrew get nodejs updated, I must change my ~/.profile manually.
Shouldn't this be marked as dupe of #1194?
This issue is solved now in v0.19.1
For example I have achieved to install surge globally.
Here log (I have ~/.npmrc prefix cofigured with my local path):
~> sudo dnf install yarn
~> yarn version
0.19.1
~> cat ~/.npmrc
prefix=/home/joseluis/.node
~> yarn config get prefix
/home/joseluis/.node
~> yarn global bin
/home/joseluis/.node/bin
~> yarn global add surge
yarn global v0.19.1
warning No license field
[1/4] Resolving packages...
warning surge > fstream-ignore > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning surge > request > [email protected]: use uuid module instead
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
- surge
warning No license field
Done in 3.04s.
~> surge --version
0.18.0
__Yarn__ reads the prefix path in ~/.npmrc file:
~> npm config get prefix
/home/joseluis/.node
~> yarn config get prefix
/home/joseluis/.node
Deleting prefix... (for testing only)
~> sed -i '/prefix=/d' ~/.npmrc
~> npm config get prefix
/usr
~> yarn config get prefix
undefined
Most helpful comment
Similar issue on macOS, I use nvm for my node environment. When I install a new version of node then
yarn globaldoes't install pkg correctlybtw I use
brewto install yarn.The information as follow