Yarn: EACCES Issue

Created on 12 Oct 2016  路  41Comments  路  Source: yarnpkg/yarn

I did not run with sudo, I did normal bash installation on Mac and then yarn install. Before running this, I cleared ~/.npm and node_modules.

screen shot 2016-10-12 at 1 58 02 am

triaged

Most helpful comment

@davidcalhoun, probably your cache folder was created by a su user.
Try removing /Users/davidcalhoun/Library/Caches/Yarn

All 41 comments

Try this to fix

$ sudo chown -R $USER /Users/nexus/.yarn-cache

That's not a fix, I never used sudo, why would there be permission errors. Something isn't right.

I also have same permission problem for sharp.

EACCES: permission denied , open '/Users/user/.yarn-cache/npm-sharp-0.16.0/include/glibconfig.h'

@niftylettuce @ubaltaci you dont have such issues with npm?

does yarn generate smth like ./npm-debug.log?

I don't have those issues, and I haven't seen any log files generated by yarn.

I'm getting the same error while trying to install sharp with yarn...npm works just fine.

I have probably the same problem. npm works. Ubuntu, PPA package install.

err

probably related to #961

@ubaltaci is probably right, The offending package has indeed wrong permissions inside. There is missing +x for lib folder.

@niftylettuce @ubaltaci Are you able to provide the permissions on the sharp file that is generating the EACCES?

ls -al ~/.yarn-cache/npm-sharp-0.16.0/include/glibconfig.h

This should hopefully reveal the user (and possibly reveal the umask, given the tarball) used by yarn when invoking node-gyp.

@lovell

-r--r--r-- 1 myusername staff 5496 Aug 10 10:59 /Users/myusername/.yarn-cache/npm-sharp-0.16.0/include/glibconfig.h

@ubaltaci Thanks, the permissions match the tarball.

$ tar tfv libvips-8.3.3-darwin-x64.tar.gz | grep glibconfig
-r--r--r-- travis/staff   5496 2016-08-10 08:59 include/glibconfig.h

My best guess would be that yarn is trying to overwrite files in its own cache.

About sharp install problems:

  1. yarn fails under OSX
  2. yarn works in Ubuntu
  3. npm works both in OSX & Ubuntu.

node was installed via nvm everywhere.

To allow sharp to be installed on OS X using yarn, I've manually updated the permissions on the glibconfig.h file in the relevant tarball to include u+w:

$ tar tfv libvips-8.3.3-darwin-x64.tar.gz | grep glibconfig
-rw-r--r-- travis/staff   5496 2016-08-10 08:59 include/glibconfig.h

The underlying cause of this problem remains, namely that yarn requires write access to files in its cache but is not currently verifying/ensuring the relevant permission to do so.

I am no longer able to reproduce this on master. can someone else verify @yarnpkg/core

test case:

yarn add sharp

@samccone sharp no longer provides a suitable test case for this problem as it has been patched to include user+write file permissions.

@samccone these are suitable test cases:

yarn add @types/[email protected]
yarn add [email protected]

I think I just ran into this when yarn was installing easy-table 0.0.1 which was pulled in via azure-cli 0.9.10 (but the latest version of azure-cli 0.10.7 also still depends on 0.0.1):

$ yarn
yarn install v0.17.8
info No lockfile found.
[1/4] Resolving packages...
warning [email protected]: use uuid module instead
warning azure-cli > [email protected]: use uuid module instead
warning stackvis > [email protected]: use uuid module instead
warning request > [email protected]: use uuid module instead
warning airbud > request > [email protected]: use uuid module instead
warning azure-cli > azure-keyvault > [email protected]: use uuid module instead
warning mocha > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning node-gyp > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning coffeelint > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning mocha > glob > [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
warning mocha > [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
warning request > [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
warning youtube-api > googleapis > request > [email protected]: use uuid module instead
warning intercom-client > babel-eslint > babel-core > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning stackvis > manta > [email protected]: IMPORTANT hotfix
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/easy-table/-/easy-table-0.0.1.tgz: EACCES: permission denied, open '/home/vagrant/.cache/yarn/npm-easy-table-0.0.1-dbd809177a1dd7afc06b4849d1ca7eff13e299eb/lib/table.js'".
info If you think this is a bug, please open a bug report with the information provided in "/srv/current/api2/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

For me, I was having issues starting a react-native app. Cleaning up cache folder from Yarn solved the problem.

sudo rm -rf /Users/<User>/Library/Caches/Yarn/*

After that, react-native init got working again.

We are also seeing a lot of this, @alcmoraes's solution works best so far.

sudo rm -rf /Users//Library/Caches/Yarn/*

Ran into Argument list too long error, worked around that via

rm -rf /Users/$USER/Library/Caches/Yarn/ && mkdir -p /Users/$USER/Library/Caches/Yarn/

Retried yarn, still got:

error An unexpected error occurred: "https://registry.yarnpkg.com/easy-table/-/easy-table-0.0.1.tgz: EACCES: permission denied, open '/Users/kvz/Library/Caches/Yarn/npm-easy-table-0.0.1-dbd809177a1dd7afc06b4849d1ca7eff13e299eb/lib/table.js'".
info If you think this is a bug, please open a bug report with the information provided in "/Users/kvz/code/api2/api2/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

I keep getting this EACCESS error during yarn or yarn add for a quite a few packages, which install just fine using npm install, however.

So falling back to npm is my workaround, but it's annoying always having to switch between the two, so I might just stick with npm entirely until these issues are sorted out for good.

@alcmoraes Thanks, that seems to fix the issue I was having with the Yarn cache directory after running yarn add request redis:

error An unexpected error occurred: "EACCES: permission denied, mkdir '/Users/davidcalhoun/Library/Caches/Yarn/npm-whatwg-fetch-2.0.1-078b9461bbe91cea73cbce8bb122a05f9e92b772'".

Now the command executes, but I'm seeing a new error pop up after installing all the new packages:
Error: EACCES: permission denied, open '/Users/davidcalhoun/.yarnrc'

@davidcalhoun, probably your cache folder was created by a su user.
Try removing /Users/davidcalhoun/Library/Caches/Yarn

Can't reproduce this issue anymore, following the steps https://github.com/yarnpkg/yarn/issues/872#issuecomment-256284723.

Please open a new one with repro steps if you see it

error An unexpected error occurred: "EACCES: permission denied, mkdir '/home/user/path/to/app/node_modules/escodegen/node_modules/estraverse'

yarn EACCES: permission denied

This worked for me:

sudo chmod -R 777 ~/Documents/path/to/project

Upgrade yarn

I've solved the issue by running ls -lah into my home folder. Noticed only .config folder was owned by root user. So..

sudo chown -R <your-username> <home-dir>/.config

Problem gone.

sudo chown -R $(whoami) /usr/local/share/man/man8

this will upgrade yarn

error in my docker container

error An unexpected error occurred: "EACCES: permission denied, unlink '/app/node_modules/.yarn-integrity'"

I fixed this by removing my node_modules directory and running yarn install again.

I fixed this by removing my node_modules directory and running yarn install again.

This was the solution for me :)

Holy shit!

I fixed this by removing my node_modules directory and running yarn install again.

It is just works well for one time! And after this time,when I run "yarn add something",the situation happened again.

error in my docker container

error An unexpected error occurred: "EACCES: permission denied, unlink '/app/node_modules/.yarn-integrity'"

I've fixed this error by specific the permission to the user, for example:

COPY --chown=pptruser:pptruser ./src .

if you are using terminal,
login with local user, and then you can run this script

sudo chown -R $USER

I was getting "Error: EACCES: permission denied, open '/var/www/.yarnrc'", when there was no .yarnrc file there at all. I added the --verbose flag and it was in fact trying to load it, the parent directory perms did not allow for even ls ing /var/www. I created that file with the right perms and it worked fine after that.

Likely unrelated but I also ended up needing a cafile /path/to/ca/bundle because we have internal certificate authorities and yarn just hangs or finishes without completing the remaining steps without cafile in the .yarnrc file.

I still get this issue. Removing node fixes it but it keeps coming back

Was this page helpful?
0 / 5 - 0 ratings