ember-cli: "ember addon foo" fails with 'permission denied'

TimsMac:tmp tjhart$ ember addon bar
version: 0.1.2
EACCES, permission denied '/usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json'
Error: EACCES
 permission denied '/usr/local/lib/node_modules/ember-cli/blueprints/addon/files/package.json'
    at Object.fs.openSync (fs.js:438:18)
    at Object.fs.writeFileSync (fs.js:977:15)
    at Class.module.exports.generatePackageJson (/usr/local/lib/node_modules/ember-cli/blueprints/addon/index.js:27:8)
    at Class.module.exports.files (/usr/local/lib/node_modules/ember-cli/blueprints/addon/index.js:78:10)
    at Class.Blueprint.install (/usr/local/lib/node_modules/ember-cli/lib/models/blueprint.js:327:36)
    at Class.module.exports.Task.extend.run (/usr/local/lib/node_modules/ember-cli/lib/tasks/install-blueprint.js:50:24)
    at Class.module.exports.Command.extend.run (/usr/local/lib/node_modules/ember-cli/lib/commands/init.js:72:29)
    at $$$internal$$tryCatch (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
    at $$$internal$$invokeCallback (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)
    at $$$internal$$publish (/usr/local/lib/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:453:11)
TimsMac:tmp tjhart$ 

Creating ember projects, building, testing, serving all work fine. This seems odd since I see reports that others can use the addon generator without issue.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 32 (18 by maintainers)

Most upvoted comments

This is just a permission issue of that file(s) specifically. First you can try to just uninstall ember-cli globally and reinstall it. If that doesn’t work, you could just dig into that folder directly and update the permissions.

Something like this should work

sudo chown -R tjhart /usr/local/lib/node_modules/ember-cli/blueprints/addon

Met the problem. When will it be fixed?

Current workaround:

sudo ember addon [addon-name]
sudo chown -R [user:group] [addon-name/]

I run sudo ember addon sample-addon

We do not support this. Be warned escalating privileges like this is a great way to screw yourselve. The permission system on you system exists for a reason.

Something like npm does not require escalated privileges, doing so in an ember-cli app gives approximately 32,000 random JS files the ability to accidentally or intentionally perform actions as root. Which means every file on your system, including local password hashes becomes readable + mutable.

just a simple typo of rmraf('/ path/to/file/iwant' (this was a mistake in npm some time ago), now has the ability to delete nearly everything on your system…