Install fails when running as root
See original GitHub issue- Operating System: Redhat 7
- Cypress Version: 2.1.0
- Browser Version:
Is this a Feature or Bug?
Bug.
Current behavior:
When installing globally, running as root, cypress fails with an EACCESS
error when creating the dist
dir.
$ npm install -g cypress
/opt/node-v8.9.1-linux-x64/bin/cypress -> /opt/node-v8.9.1-linux-x64/lib/node_modules/cypress/bin/cypress
> cypress@2.1.0 postinstall /opt/node-v8.9.1-linux-x64/lib/node_modules/cypress
> node index.js --exec install
EACCES: permission denied, mkdir '/opt/node-v8.9.1-linux-x64/lib/node_modules/cypress/dist'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress@2.1.0 postinstall: `node index.js --exec install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cypress@2.1.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
One possible solution is having the dist
dir created in the npm release so that the postinstall script doesn’t have to create it.
Desired behavior:
Cypress should have no problems creating that directory when running as root.
Additional Info (images, stack traces, etc)
Cypress does not provide any stacktraces, because callbacks to the underlying filesystem lib isn’t provided. But I was able to pin-point that the error occurs when trying to output JSON: https://github.com/cypress-io/cypress/blob/ae794d1f8c2b68ed63ce2b9fff5fb5160d9ad74b/cli/lib/tasks/info.js#L76-L80
The fourth argument to fs.outputJsonAsync()
is a callback which receives any errors, and when modifying the code with this, the stack trace then points to the mkdir.mkdirs()
function:
at /opt/node-v8.9.1-linux-x64/lib/node_modules/cypress/lib/tasks/info.js:94:13
at mkdir.mkdirs.err (/opt/node-v8.9.1-linux-x64/lib/node_modules/cypress/node_modules/fs-extra/lib/json/output-json.js:21:23)
at xfs.stat (/opt/node-v8.9.1-linux-x64/lib/node_modules/cypress/node_modules/fs-extra/lib/mkdirs/mkdirs.js:55:43)
at /opt/node-v8.9.1-linux-x64/lib/node_modules/cypress/node_modules/graceful-fs/polyfills.js:284:29
at FSReqWrap.oncomplete (fs.js:152:21)
However, the original error is when the mkdir.mkdirs()
function calls graceful-fs.mkdir()
which in turn is fs.mkdir()
:
https://nodejs.org/api/fs.html#fs_fs_mkdir_path_mode_callback
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (2 by maintainers)
Top GitHub Comments
You should be able to install using:
sudo npm install --unsafe-perm=true --allow-root cypress
However that is not recommended. I installed npm using a nvm and it worked without sudo. npm docs: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-node-js-and-npm
I have the same issue with cypress@6.5.0. I’m running the install as a root user so I have the permissions. I also tried “npm install --unsafe-perm=true --allow-root cypress” but it did’t work for me. Does anyone have an idea what might fix it?