Open Taytay opened 7 years ago
Hmm this is tricky... We probably need to chown
the directory to the real user ID if it's different from the effective user ID.
Same with 0.17.6
yarn should warn if called with sudo or by root, like bower, file permissions are out of control by package manager, in my opinion.
What does npm do in this case?
I feel like chowning ~/.yarn
to the real user ID is fine, and would solve this problem.
I cannot reproduce this issue following the exact same steps on (after deleting all temporary yarn directories):
Also tried to install yarn through npm install -g yarn
, which got version 0.17.9, and still cannot reproduce.
$ sudo find / -name '.roadrunner.json' -ls
1973661 44 -rw-r--r-- 1 root root 42635 Nov 29 08:19 /usr/local/share/.cache/yarn/.roadrunner.json
6556939 44 -rw-rw-r-- 1 gtirloni gtirloni 43499 Nov 29 08:19 /home/gtirloni/.cache/yarn/.roadrunner.json
Got the same when I updated Yarn to 0.17.9
same error with 0.17.10 Error: EACCES: permission denied, open '/Users/RiCoTeRoX/Library/Caches/Yarn/.roadrunner.json
My solution was to change the owner.
So how did you change the owner? @RiCoTeRoX ... I have tried what I know, I'll be glad if you could be of assistance.
chown -R youruser:yourgroup *
For those who might need a bit more solution detail (or stop-gap solution, if you will):
# Show all yarn binaries in the path
$ which -a yarn | xargs ls -lA
lrwxrwxrwx 1 root root 36 Dec 8 16:12 /usr/bin/yarn -> ../lib/node_modules/yarn/bin/yarn.js
lrwxrwxrwx 1 root root 58 Dec 8 15:32 /usr/local/bin/yarn -> ../share/.config/yarn/global/node_modules/yarn/bin/yarn.js
# Show all yarn binaries in the path, but follow the symlinks
$ which -a yarn | xargs ls -lAH
-rw-r--r-- 1 root root 873 Dec 8 16:12 /usr/bin/yarn
# ^ ^ ^ Here is the issue, no run permission (x) for anyone!
-rwxr-xr-x 1 root root 873 Dec 8 15:32 /usr/local/bin/yarn
# Set the run permission for everyone on the problem binary.
$ xargs sudo chmod a+x /usr/bin/yarn
Edit: Clarity of code and typos
Unfortunately, I am also encountering this issue. :(
Do you want to request a feature or report a bug? BUG
What is the current behavior?
If you run
yarn
as root for its first run: for example:sudo yarn --version
then yarn creates~/.yarn
and~/.yarn/.roadrunner.json
with the permissions and ownership like so:Subsequent runs of yarn as a normal user fail because they cannot read .roadrunner.json:
If the current behavior is a bug, please provide the steps to reproduce.
sudo npm install -g yarn
sudo yarn --version
yarn --version
What is the expected behavior? I would have expected to be able to run yarn after running it as sudo once.
Please mention your node.js, yarn and operating system version.
Yarn version: 0.16.1
Node version: 4.6.1
Platform: linux x64