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

eaccess permission denied when trying to use yo #282

Closed
allenwzj opened this issue Jul 22, 2014 · 39 comments

Comments

@allenwzj
Copy link

commented Jul 22, 2014

eaccess permission denied when trying to use yo

root@precise64:~/local# yo
[?] 'Allo root! What would you like to do? (Use arrow keys)
‣ Install a generator
Find some help
Get me out of here!
/usr/lib/node_modules/yo/node_modules/insight/node_modules/configstore/configstore.js:66
throw err;
^
Error: EACCES, permission denied '/root/.config/configstore/insight-yo.yml'
You don't have access to this file.

at Object.fs.openSync (fs.js:432:18)
at Object.fs.writeFileSync (fs.js:971:15)
at Object.create.all.set (/usr/lib/node_modules/yo/node_modules/insight/node_modules/configstore/configstore.js:56:8)
at Object.Configstore (/usr/lib/node_modules/yo/node_modules/insight/node_modules/configstore/configstore.js:19:11)
at new Insight (/usr/lib/node_modules/yo/node_modules/insight/lib/insight.js:23:34)
at process.<anonymous> (/usr/lib/node_modules/yo/node_modules/insight/lib/push.js:11:16)
at process.emit (events.js:98:17)
at handleMessage (child_process.js:322:10)
at Pipe.channel.onread (child_process.js:349:11)

Thank you in advance.

@SBoudrias

This comment has been minimized.

Copy link
Member

commented Jul 22, 2014

permission denied '/root/.config/configstore/insight-yo.yml'
You don't have access to this file.

Google for chmod

@SBoudrias SBoudrias closed this Jul 22, 2014

@allenwzj

This comment has been minimized.

Copy link
Author

commented Jul 23, 2014

Thank you.

@goids

This comment has been minimized.

Copy link

commented Oct 3, 2014

Not work. "chmod 777 /root/.config/configstore/insight-yo.yml" and no work

@SBoudrias

This comment has been minimized.

Copy link
Member

commented Oct 3, 2014

sudo the chmod command if needed - if you can't read it, you can't change permissions.

@goids

This comment has been minimized.

Copy link

commented Oct 3, 2014

I use debia 7, and my user is root, look this line code.


Error: EACCES, permission denied '/root/.config/configstore/yo.yml'
You don't have access to this file.

    at Object.fs.openSync (evalmachine.<anonymous>:438:18)
    at Object.fs.readFileSync (evalmachine.<anonymous>:289:15)
    at Object.create.all.get (/root/.node/lib/node_modules/yo/node_modules/configstore/configstore.js:33:29)
    at Object.Configstore (/root/.node/lib/node_modules/yo/node_modules/configstore/configstore.js:26:44)
    at Object.<anonymous> (/root/.node/lib/node_modules/yo/yoyo.js:19:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
chmod: no se puede acceder a «root/.config/configstore/yo.yml»: No existe el fichero o el directorio

File no exist, Why?

@SBoudrias

This comment has been minimized.

Copy link
Member

commented Oct 3, 2014

Maybe you deleted the file now? But the file can't have permissions denied and not exist - it's one or the other.

@goids

This comment has been minimized.

Copy link

commented Oct 3, 2014

I have not removed, I reinstalled "Yoeman" and not create that file.

sudo npm install --global yo --allow-root
/root/.node/bin/yo -> /root/.node/lib/node_modules/yo/cli.js

> yo@1.3.0 postinstall /root/.node/lib/node_modules/yo
> node ./scripts/doctor

[Yeoman Doctor] Everything looks alright!

yo@1.3.0 /root/.node/lib/node_modules/yo
├── is-root@1.0.0
├── sudo-block@1.0.0
├── fullname@1.0.0
├── opn@1.0.0
├── async@0.9.0
├── string-length@1.0.0 (strip-ansi@2.0.0)
├── yeoman-character@1.0.0 (supports-color@1.1.0)
├── nopt@3.0.1 (abbrev@1.0.5)
├── shelljs@0.3.0
├── chalk@0.5.1 (escape-string-regexp@1.0.2, ansi-styles@1.1.0, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
├── findup@0.1.5 (commander@2.1.0, colors@0.6.2)
├── multiline@1.0.0 (strip-indent@1.0.0)
├── underscore.string@2.3.3
├── lodash@2.4.1
├── yosay@1.0.0 (ansi-styles@1.1.0, ansi-regex@1.1.0, strip-ansi@2.0.0, pad-component@0.0.1, word-wrap@0.1.3, minimist@1.1.0, taketalk@0.1.1)
├── update-notifier@0.2.2 (is-npm@1.0.0, semver-diff@2.0.0, latest-version@1.0.0)
├── configstore@0.3.1 (object-assign@0.3.1, osenv@0.1.0, graceful-fs@3.0.2, uuid@1.4.2, mkdirp@0.5.0, js-yaml@3.0.2)
├── insight@0.4.3 (object-assign@1.0.0, os-name@1.0.0, tough-cookie@0.12.1, lodash.debounce@2.4.1, request@2.44.0, inquirer@0.6.0)
└── yeoman-generator@0.17.7 (dargs@2.0.3, diff@1.0.8, class-extend@0.1.1, rimraf@2.2.8, github-username@1.0.0, text-table@0.2.0, mime@1.2.11, isbinaryfile@2.0.1, mkdirp@0.5.0, grouped-queue@0.3.0, debug@1.0.4, cross-spawn@0.2.3, run-async@0.1.0, iconv-lite@0.4.4, findup-sync@0.1.3, file-utils@0.2.1, glob@4.0.6, request@2.44.0, cheerio@0.17.0, gruntfile-editor@0.2.0, download@1.0.7, inquirer@0.7.3)
@battlesnake

This comment has been minimized.

Copy link

commented Nov 26, 2014

I'm getting this too:

Permissions:

-> whoami
root

-> stat /root /root/.config /root/.config/configstore /root/.config/configstore/insight-yo.yml -c "%A | %U | %n"
drwxr-x--- | root | /root
drwx------ | root | /root/.config
drwx------ | root | /root/.config/configstore
-rw-r--r-- | root | /root/.config/configstore/insight-yo.yml

Output:

-> yo create test

Error: EACCES, permission denied '/root/.config/configstore/insight-yo.yml'
You don't have access to this file.

    at Object.fs.openSync (evalmachine.<anonymous>:438:18)
    at Object.fs.readFileSync (evalmachine.<anonymous>:289:15)
    at Object.create.all.get (/usr/lib/node_modules/yo/node_modules/configstore/configstore.js:33:29)
    at Object.Configstore (/usr/lib/node_modules/yo/node_modules/configstore/configstore.js:26:44)
    at new Insight (/usr/lib/node_modules/yo/node_modules/insight/lib/index.js:26:34)
    at Object.<anonymous> (/usr/lib/node_modules/yo/cli.js:123:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

Yeoman version (yo -v gives error, I used npm info -g yo):
1.3.3

@battlesnake

This comment has been minimized.

Copy link

commented Nov 26, 2014

Fixed it with:

chmod g+rwx /root /root/.config /root/.config/configstore

For some reason, it wanted group permissions on the parent directories even though it already had rwx via user permissions.

@nisaacson

This comment has been minimized.

Copy link

commented Nov 30, 2014

Thanks @battlesnake that worked for me

@zero1zero

This comment has been minimized.

Copy link

commented Dec 2, 2014

I'm still getting this error and am unable to find a workaround. I'm installing and running with root, but my .config directory is not being created at all, even with --allow-root in the npm command.

Any ideas?

@SBoudrias

This comment has been minimized.

Copy link
Member

commented Dec 2, 2014

@zero1zero Like we said, this is a permission issue, chmod/chown your folder so your user can read/write to them.

@zero1zero

This comment has been minimized.

Copy link

commented Dec 2, 2014

I've been trying that but the directory does not appear to exist:

Step 5 : RUN npm install -g yo --allow-root generator-hubot coffee-script --save
 ---> Using cache
 ---> ee64dd037c05
Step 6 : RUN chmod g+rwx /root /root/.config /root/.config/configstore
 ---> Running in bbf9041226c9
chmod: cannot access '/root/.config': No such file or directory
chmod: cannot access '/root/.config/configstore': No such file or directory

This is in a docker container so everything is being run as root. Is my install command incorrect?

@paulobar

This comment has been minimized.

Copy link

commented Dec 15, 2014

Had the same problem.
Just saying: the files are not being created when yeoman is installed.
So no chown or chmod will do anything useful.
But I guess you guys are not reading.

Well, I don't need yeoman really, so I just posted to confirm: that is a real issue and you guys should read what people are posting.

@SBoudrias

This comment has been minimized.

Copy link
Member

commented Dec 15, 2014

@zero1zero @paulobar If the root directory is not writable, you won't be able to go further. You have all the tools to fix the issue, just chmod the path so it is writable. This mean chmod whatever directory is causing the issue.

@zero1zero

This comment has been minimized.

Copy link

commented Dec 15, 2014

I have reiterated a few times that, as far as I can tell, I have all the correct permissions.

Here is my docker log that shows my current user and the permissions of the /root/ directory:

Step 7 : RUN ls -ld /root
 ---> Running in d7bbd47194ff
drwx------ 2 root root 4096 Sep 23 07:35 /root
Step 8 : RUN whoami
 ---> Running in e929ac6290ec
root
Step 9 : RUN npm install -g generator-hubot coffee-script --save
<snip>
Step 10 : RUN chmod g+rwx /root /root/.config /root/.config/configstore
 ---> Running in 11050bea20fd
chmod: cannot access '/root/.config': No such file or directory
chmod: cannot access '/root/.config/configstore': No such file or directory

This shows that I am the root user and the permissions of the /root directory are 700. I am clear on the semantics and use of chmod, but from every indication, this directory is not being created. Is there another troubleshooting step you might recommend to help get more information on the behavior I'm seeing?

@md5

This comment has been minimized.

Copy link

commented Dec 15, 2014

Yeoman is switching root to UID 501, so /root would have to be writable by that (possibly non-existent) user.

I ended up giving up on running yo as root in a Docker container because it really doesn't want to do so.

@md5

This comment has been minimized.

Copy link

commented Dec 15, 2014

@md5

This comment has been minimized.

Copy link

commented Dec 15, 2014

I also gave up in the specific case of generator-hubot because I don't think the Dockerfile should be running it. The result of running the generator on a local box should be included in the Dockerfile. All you want to do in the Dockerfile itself is npm install from the generated package.json.

@paulobar

This comment has been minimized.

Copy link

commented Dec 16, 2014

The point is I am root, so... But never mind. Really

@md5

This comment has been minimized.

Copy link

commented Dec 16, 2014

@paulobar even if you run yo hubot or whatever as root, yo ends up calling process.setuid(501) right here.

This means that if it needs to create /root/.config/configstore/insight-yo.yml or any of its parent directories, that is going to happen with EUID is 501, not 0. This is why the workarounds people have suggested involve opening up the permissions of /root/.config/configstore, etc.

@SBoudrias

This comment has been minimized.

Copy link
Member

commented Dec 16, 2014

Yeoman don't allow to run as root because it broke to many people computer. If you're not able to change permissions on a folder, imagine those people who don't even know what sudo really involve...

Anyway, usually changing the UID to 501 fail if there's no default user. I'm surprise it didn't let you know the user didn't exist.

Anyway, the takeaway is to not run Yeoman as root.

@md5

This comment has been minimized.

Copy link

commented Dec 16, 2014

process.setuid (or the setuid(2) system call) doesn't care if the user exists or not.

If Yeoman should not be run as root, so be it. But in my opinion this process.setuid code should be scrapped. All it does it change the effective UID, but it doesn't actually change $HOME or anything else,
hence the broken behavior we're seeing with Configstore trying to create files under /root as UID 501. In the case that user 501 does exist, it seems totally arbitrary to choose that user and possibly create stuff under ~/.config for them as a side effect of Yeoman trying to generate a file.

All that being said, I'm happy to accept that Yeoman can't be run as root, it just shouldn't pretend like it can and do this hidden, undocumented setuid stuff.

@jovanialferez

This comment has been minimized.

Copy link

commented Dec 17, 2014

@paulobar @zero1zero i fixed (workaround) mine inside of Docker by setting ownership of /root to 501.

@igoreliasm

This comment has been minimized.

Copy link

commented Jan 3, 2015

try the procedure:

echo prefix = ~/.node >> ~/.npmrc
export PATH=$HOME/.node/bin:$PATH
@paulobar

This comment has been minimized.

Copy link

commented Jan 4, 2015

@md5 I subscribe to your view. Using an arbitrary user id is problematic. And solemnly swear that I shall never again run Yeoman as root. Thank you all.

@walkerwzy

This comment has been minimized.

Copy link

commented Jan 6, 2015

@igoreliasm it works for me, tks

@DantewithZYX

This comment has been minimized.

Copy link

commented Jan 6, 2015

.config was missing for me too. (on Mac) Turned out the owner of my /Users/MyName/ folder was not the user I had installed node and npm with, who had ownership of those files. Once I logged into the other user on my mac who actually had ownership of the root directory /Users/MyName/ and reinstalled everything fresh, it worked great. Could have probably logged in as root and changed the owner of my root folder on my initial account but switching to the other user is fine too. Make sure you cd /Users/ and ls -l and make sure the user you're installing with is actually the owner of your root directory.

Stupid mac problem, because I had to create new user when I got my new mac, even tho I migrated my previous user from my old mac and normally use that. But this new user I've never actually used before had ownership of my normal account's root directory..took way to long to figure out. This thread did help tho! Thanks!

@estani

This comment has been minimized.

Copy link

commented Jan 12, 2015

It took me a while to figure out, but:

npm -g install yo will install the module in /usr/local/lib/node_modules/ (so you need root rights for this)

calling yo will create some config files in $HOME/.config/configstore/* (for user tracking, etc)
and there's the requirement that $HOME must be owned by any user but root.

So for docker: install normally and add a user and set $HOME to that user home at the end of your Dockerfile.

@mandb

This comment has been minimized.

Copy link

commented Jan 16, 2015

Just make the folder "configstore" it's looking for...

yo -v

Error: EACCES, permission denied '/root/.config/configstore/insight-yo.yml'
You don't have access to this file.

at Object.fs.openSync (evalmachine.<anonymous>:439:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:290:15)
at Object.create.all.get (/usr/lib/node_modules/yo/node_modules/configstore/index.js:34:29)
at Object.Configstore (/usr/lib/node_modules/yo/node_modules/configstore/index.js:27:44)
at new Insight (/usr/lib/node_modules/yo/node_modules/insight/lib/index.js:26:34)
at Object.<anonymous> (/usr/lib/node_modules/yo/cli.js:123:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

mkdir /root/.config/configstore
chmod g+rwx /root /root/.config /root/.config/configstore

yo -v

1.3.3

This is caused because yo launches node as user 501, instead of the currently running user, so it cannot create folders that it requires.

image

This seems to be by intention, when running it as the root user.

/usr/bin/yo (line 24):

  function rootCheck() {
     if (isRoot() && process.setuid) {
       try {
          // Try to force yo to run on a safe uid
          process.setuid(501);
        } catch (err) {}
    }
@SBoudrias

This comment has been minimized.

Copy link
Member

commented Jan 16, 2015

@mandb yo only fallback to a safe uid if you run yo as sudo.

@mandb

This comment has been minimized.

Copy link

commented Jan 16, 2015

Perhaps it could fail more elegantly if run as root, some verbose maybe?

@SBoudrias

This comment has been minimized.

Copy link
Member

commented Jan 16, 2015

@mandb that's what we had before and people complained, so we made this fix and it's been better since.

@mandb

This comment has been minimized.

Copy link

commented Jan 16, 2015

Wrong side of the fence I guess! 👍

@OKNoah

This comment has been minimized.

Copy link

commented Feb 1, 2015

I had this error as well and fixed it by making a new user and not running yo hubot with sudo. But at the end of the hub configuration it fails and says I should run again as root.

npm ERR! Error: EACCES, mkdir '/home/my-user/.npm/commander/1.3.2'
npm ERR!  { [Error: EACCES, mkdir '/home/my-user/.npm/commander/1.3.2']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/home/my-user/.npm/commander/1.3.2',
npm ERR!   parent: 'express' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

Maybe this is more of an npm issue now?

@OKNoah

This comment has been minimized.

Copy link

commented Feb 1, 2015

@atomi

This comment has been minimized.

Copy link

commented Feb 9, 2015

@SBoudrias Yours is a bad solution. It creates problems for people that know what they're doing Yeoman should block root altogether unless a command line flag is set (if using root created a problem for newbs). Do not change UID, especially without even telling the user.

By the way, it's generally safe to run as root in containers.

@passy

This comment has been minimized.

Copy link
Member

commented Feb 11, 2015

@atomi Since we put that safe-guard in place, we've dramatically reduced the number of cases where people would completely screw their system. We want Yeoman to be as approachable as possible to newcomers and hence this choice is a very important and effective one.

At least for Docker containers it's easy enough to run commands in a user context.

@atomi

This comment has been minimized.

Copy link

commented Feb 11, 2015

@passy Yeah. It's incredibly inconvenient and it won't work if the mounted project directory is a different user. Which means you now have to change the Dockerfile to match the uid of your project. Now docker pull won't automatically work.

Bower does a good job at handling the issue with --allow-root you can do that.

@yeoman yeoman locked and limited conversation to collaborators Mar 9, 2015

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.