question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
ryparkercommented, Mar 15, 2019

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

2reactions
valentina98commented, Feb 19, 2021

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can i resolve this error when installing ROOT
i am installing root in workstation that has number of processor 72 so should i install another version of cmake or is it...
Read more >
db2iupdt fails when run as root - Forums - IBM Support
db2iupdt fails when run as root. The install is a root install. The ownership of the db2iupdt file is root. Permissions are fine....
Read more >
Must be run as root to install this package.' when patching Mac ...
GFI LanGuard shows the following error in the Remediation Jobs tab when patching a Mac computer: installer: Must be run as root to...
Read more >
How do I run a command as root? [duplicate] - Ask Ubuntu
run) and tried to install within a terminal. When I started the installation process I got this error: ERROR: nvidia-installer must be run...
Read more >
AI Install Fails with: Sorry, user root is not allowed to execute ...
Diagnosing/Resolving · Typically this happens when the user running the script does not have sudo permissions. Run the command: sudo -l -U <user ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found