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

EACCES: permission denied on yarn install #1806

Closed
matart15 opened this issue Nov 14, 2016 · 34 comments
Closed

EACCES: permission denied on yarn install #1806

matart15 opened this issue Nov 14, 2016 · 34 comments

Comments

@matart15
Copy link

Do you want to request a feature or report a bug?
bug

What is the current behavior?
react native project yarn install gives me this error

  Error: EACCES: permission denied, open '/Users/username/workplace/react_native/project/node_modules/react-native-maps/android/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/9.4.0/AndroidManifest.xml'

I tried chmod 777 the file. but error is same even there is 777 permission

Please mention your node.js, yarn and operating system version.
npm -v : 3.10.9
node -v : v7.1.0

@rogervila
Copy link

try sudo yarn install, and post the yarn.log content

@matart15
Copy link
Author

OK sudo did it.

Is sudo yarn safe?. I mean its safe in react native but is it safe in general?

@rogervila
Copy link

It's always better to run it without sudo, but the fact that it has worked means that is not a yarn bug.
I assume that you are on Ubuntu or OSX. Try sudo chmod 0777 the-project-path, and then remove the node_modules path and theyarn.lock file. Then run yarn

@wyze wyze removed the needs triage label Nov 14, 2016
@ZhihaoLau
Copy link

@rogervila does not working for me. I previous have .git in the-project-path, that command changed everything in my repo. So, It get worst.

@ZhihaoLau
Copy link

But sudo chmod -R 777 node_module just fine

@matart15
Copy link
Author

@rogervila seems like few more people have same problem.

yarn install works with sudo. But npm install works on same folder without sudo.
is it yarn problem? do you think it should be fixed?

@rogervila
Copy link

@ziolau @matart15 Could you share your package.json? I will try to reproduce it.
What OS version do you have?

@matart15
Copy link
Author

matart15 commented Nov 15, 2016

for me i created brand new ignite project and tried to add react-native-camera.

{
  "name": "App",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "lint": "standard --verbose | snazzy",
    "lintdiff": "git diff --name-only --cached --relative | grep '\\.js$' | xargs standard | snazzy",
    "fixcode": "standard --fix",
    "clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean",
    "newclear": "rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build/ModuleCache/* && rm -rf node_modules/ && npm cache clean && npm i",
    "test": "NODE_ENV=production ava",
    "test:watch": "ava --watch",
    "coverage": "nyc ava && nyc report --reporter=html && open coverage/index.html || xdg-open coverage/index.html",
    "tron": "node_modules/.bin/reactotron",
    "android:build": "cd android && ./gradlew assembleRelease",
    "android:install": "cd android && ./gradlew assembleRelease && ./gradlew installRelease",
    "android:hockeyapp": "cd android && ./gradlew assembleRelease && puck -submit=auto app/build/outputs/apk/app-release.apk",
    "android:devices": "$ANDROID_HOME/platform-tools/adb devices",
    "android:logcat": "$ANDROID_HOME/platform-tools/adb logcat *:S ReactNative:V ReactNativeJS:V",
    "android:shake": "$ANDROID_HOME/platform-tools/adb devices | grep '\\t' | awk '{print $1}' | sed 's/\\s//g' | xargs -I {} $ANDROID_HOME/platform-tools/adb -s {} shell input keyevent 82",
    "flow": "flow --show-all-errors; test $? -eq 0 -o $? -eq 2"
  },
  "dependencies": {
    "apisauce": "^0.5.0",
    "format-json": "^1.0.3",
    "querystringify": "0.0.4",
    "ramda": "^0.22.1",
    "react": "~15.3.0",
    "react-native": "^0.36.0",
    "react-native-animatable": "^0.6.0",
    "react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git",
    "react-native-config": "^0.1.0",
    "react-native-device-info": "^0.9.5",
    "react-native-drawer": "^2.3.0",
    "react-native-i18n": "^0.1.1",
    "react-native-maps": "^0.11.0",
    "react-native-router-flux": "^3.35.0",
    "react-native-vector-icons": "^2.1.0",
    "react-redux": "^4.4.2",
    "redux": "^3.6.0",
    "redux-logger": "^2.4.0",
    "redux-persist": "^3.5.0",
    "redux-saga": "^0.11.1",
    "reduxsauce": "0.2.0",
    "seamless-immutable": "^6.1.0"
  },
  "devDependencies": {
    "ava": "^0.16.0",
    "babel-eslint": "^7.0.0",
    "babel-preset-es2015": "^6.14.0",
    "enzyme": "^2.3.0",
    "flow-bin": "^0.33.0",
    "ghooks": "^1.3.2",
    "mockery": "^1.7.0",
    "nyc": "^8.1.0",
    "react-addons-test-utils": "^15.3.2",
    "react-dom": "^15.3.2",
    "react-native-mock": "^0.2.7",
    "reactotron-apisauce": "^1.3.0",
    "reactotron-react-native": "^1.3.0",
    "reactotron-redux": "^1.3.1",
    "snazzy": "^5.0.0",
    "standard-flow": "^1.0.0"
  },
  "ava": {
    "files": [
      "Tests/**/*.js",
      "!Tests/Setup.js"
    ],
    "require": [
      "babel-register",
      "babel-polyfill",
      "react-native-mock/mock",
      "./Tests/Setup"
    ],
    "babel": "inherit"
  },
  "standard": {
    "parser": "babel-eslint",
    "globals": [
      "describe",
      "it",
      "fetch",
      "navigator",
      "__DEV__",
      "XMLHttpRequest",
      "FormData",
      "React$Element"
    ]
  },
  "config": {
    "ghooks": {
      "pre-commit": "if [ -d 'ignite-base' ]; then cd ignite-base; fi; npm run lint"
    }
  }
}

Mac Sierra
npm -v : 3.10.9
node -v : v7.1.0

@rogervila
Copy link

rogervila commented Nov 15, 2016

I tried it in an empty folder, and had no problems with:

  • Yarn 0.16.1 & 0.17.0
  • OSX 10.11 El Capitan
  • Node 6.2.2
  • Npm 3.10.3

As I can see, the error happens to you when it tries to access to AndroidManifest.xml. Which service does need this file?

Maybe the error occurs after yarn and is related to ignite. Did you try to run yarn in an empty folder with only the package.json?

@ryankask
Copy link

These are Android build artfacts related to react-native. If you use a react-native package that requires Google Play Services, it looks like this issue comes up. You need to actually run Gradle for these to be downloaded (which is of course after Yarn runs).

The artifacts have a permission of -r-xr-xr-x which yarn doesn't like. I'm not sure why the files Gradle downloads have that permission or why yarn needs to write to them.

This is my initial read of the issue. I haven't looked into it any further.

@ericnograles
Copy link

Ran into this issue myself with a React Native app as well.

Running cd ./android && ./gradlew clean seems to clean up the EACCES issues for me.

@matart15
Copy link
Author

i tried cd ./android && ./gradlew clean one. But did not change. So i returned back to npm for now.

@koffeinfrei
Copy link

@rogervila / @ziolau opening up your project folder to everyone is not a very advisable solution.

@egold
Copy link

egold commented Jan 20, 2017

chmod -R u+w /your/project/directory

Is probably the way to go. This makes your unix user (u) have write access recursively (-R) in your project directory. Instead of playing whackamole on each messed up permission, or blanket making all things world read-write-execute-able.

@NexusInk
Copy link

NexusInk commented Jan 16, 2018

After installing nvm for node versioning in Ubuntu 16.04 yarn install threw EACCES errors.
I I tried sudo yarn install with no success.
After mixing & matching various assets with sudo and without. I get locked folders.
sudo chmod -R 777 path/to//project
and then yarn or yarn install
seemed to do the trick.

I'll have to remove privileges later but I'll cross that bridge when I get there.
Thanks

@shukriadams
Copy link

Getting this on ubuntu 16.04 in vagrant, yarn is trying to access my ~/.config/ folder which is set to
drwx------

Not sure why it's locked down so tight, would rather open that though, than run yarn with sudo.

@cdimitroulas
Copy link

Just as a note to others - following @NexusInk's advice got me in all sorts of trouble. Change the permissions of all the files in a project broke all sorts of things including git.
Had to figure out what the correct permissions were for all the src files, certain git internals etc. before I was able to get the project directory back in order.
Not recommended.

Not sure what a better solution to this bug is though.

@arpowers
Copy link

arpowers commented Mar 3, 2019

what @cdimitroulas is referring to is "file mode" in .git. Git tracks file permissions by default so you'll need to disable this or just commit the file permissions change to your repo, which may or may not be relevant

@hufancia03
Copy link

This method works mine. (MacOSX (Mojave))

  • brew uninstall --force yarn
  • rm -rf "$HOME/.yarn
  • brew install yarn --ignore-dependencies
  • yarn install

@BlueRaja
Copy link

BlueRaja commented Jun 10, 2020

I get this after running yarn upgrade-interactive on a repo. Deleting yarn caches or node_modules does not fix it, nor does chmod or chown.

The only solution I've found is to delete the entire repo and check it out again from git.

@xinluantian
Copy link

If you are using mac, you can try with homebrew.
brew install yarn

pconrad added a commit to brownfield-team/anacapa-github-linker that referenced this issue Aug 23, 2020
@guillemlc
Copy link

But sudo chmod -R 777 node_module just fine

How are these 'solutions' acceptable solutions?

@seanryanuk
Copy link

This may be a little late, but here's an observation made recently after inheriting an old early 2011 macbook pro.

I'm a web dev, so I installed the node stack, but because this beaut is an old girl now, I can't rely on brew too heavily as I can only go up to macOS 10.13 now. Mostly manual installs.

So after doing so, noticed my /Users/[user]/.config folder was permission set to root:staff, probably a side effect of the install process, my best guess? Using sudo in the nvm installation (as directed) had some side effect.

Just note the file it's trying to access in the error message (mine was Error: EACCES: permission denied, open '/Users/tech1337/.config/yarn'), which led me to the issue. I just did chown -R [user] ~/.config and voilá!

Hope this helps someone out there!

adaliszk added a commit to adaliszk/node-toolbox that referenced this issue Dec 6, 2021
@juanssal
Copy link

Had similar issue, so I installed yarn globally and then ran sudo yarn, and it did the trick.

@serendatapy
Copy link

serendatapy commented Mar 21, 2022

It's always better to run it without sudo, but the fact that it has worked means that is not a yarn bug. I assume that you are on Ubuntu or OSX. Try sudo chmod 0777 the-project-path, and then remove the node_modules path and theyarn.lock file. Then run yarn

In my case it was sufficient to remove the node_modules & yarn.lock and run 'yarn', the permission change or sudo wasn't necessary.

Could the problem have been caused because I moved the files on folder up after the initial installation?

@zlh562011966
Copy link

remove all yarn files;
then, npm install -g yarn

@AndreKR
Copy link

AndreKR commented Aug 5, 2022

In my case the reason was that I was running yarn via package.json -> scripts and npm run and apparently the npm developers thought it was a good idea to change the effective user id (without logging a message, without changing the home directory, without even checking if the user exists) when running scripts.

@ojolowoblue
Copy link

sudo npm i yarn --global
Works for me

@tech-doctor
Copy link

sudo npm i yarn --global

It works for me too. thank you.

1 similar comment
@tech-doctor
Copy link

sudo npm i yarn --global

It works for me too. thank you.

@VincentWasswa
Copy link

sudo npm i yarn --global works like a charm

@Gabriel-Aquino
Copy link

Gabriel-Aquino commented Mar 30, 2023

It's always better to run it without sudo, but the fact that it has worked means that is not a yarn bug. I assume that you are on Ubuntu or OSX. Try sudo chmod 0777 the-project-path, and then remove the node_modules path and theyarn.lock file. Then run yarn

In my case, I've deleted node_modules and yarn.lock and run yarn add [libToInstall] and it works. Thank you

@tspearconquest
Copy link

Just as a note to others - following @NexusInk's advice got me in all sorts of trouble. Change the permissions of all the files in a project broke all sorts of things including git. Had to figure out what the correct permissions were for all the src files, certain git internals etc. before I was able to get the project directory back in order. Not recommended.

Not sure what a better solution to this bug is though.

Easy generic way to get most permissions fixed: find . -type f -exec chmod 644 '{}' \; && find . -type d -exec chmod 755 '{}' \;

You could also just rm -rf your local copy and re-clone.

If you do the permissions fix, once you have files at 644 and directories at 755, you can make adjustments as needed for your project.

@eek
Copy link

eek commented Sep 14, 2023

I have the same problem on MacOS, it's weird that yarn requires sudo for install.

This fix seems to work: sudo chown -R $USER:$GROUP ~/.config

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

No branches or pull requests