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

Permission denied on cacheDirectory even with --no-cache #2141

Closed
cizar opened this issue Nov 21, 2016 · 5 comments
Closed

Permission denied on cacheDirectory even with --no-cache #2141

cizar opened this issue Nov 21, 2016 · 5 comments

Comments

@cizar
Copy link

cizar commented Nov 21, 2016

It is not possible to run jest on the same host that was previously run jest by other user. I'm setting up my Ubuntu 16.04 with Jenkins and when the job executes jest, the /tmp/jest directory is created and is owned by the jenkins user.

cesar@fozzie:~/demo$ ls -ald /tmp/jest/
drwxr-xr-x 3 jenkins jenkins 4096 nov 20 23:13 /tmp/jest/

Then, when I try to run npm test on my local copy the execution fails, even with the --no-cache flag active.

cesar@fozzie:~/demo$ ./node_modules/.bin/jest --debug --no-cache
jest version = 17.0.3
test framework = jasmine2
config = {
  "rootDir": "/home/cesar/demo",
  "name": "-home-cesar-demo",
  "setupFiles": [],
  "testRunner": "/home/cesar/demo/node_modules/jest-jasmine2/build/index.js",
  "transform": [
    [
      "^.+\\.jsx?$",
      "/home/cesar/demo/node_modules/babel-jest/build/index.js"
    ]
  ],
  "usesBabelJest": true,
  "automock": false,
  "bail": false,
  "browser": false,
  "cacheDirectory": "/tmp/jest",
  "coveragePathIgnorePatterns": [
    "/node_modules/"
  ],
  "coverageReporters": [
    "json",
    "text",
    "lcov",
    "clover"
  ],
  "expand": false,
  "globals": {},
  "haste": {
    "providesModuleNodeModules": []
  },
  "mocksPattern": "__mocks__",
  "moduleDirectories": [
    "node_modules"
  ],
  "moduleFileExtensions": [
    "js",
    "json",
    "jsx",
    "node"
  ],
  "moduleNameMapper": {},
  "modulePathIgnorePatterns": [],
  "noStackTrace": false,
  "notify": false,
  "preset": null,
  "resetMocks": false,
  "resetModules": false,
  "snapshotSerializers": [],
  "testEnvironment": "jest-environment-jsdom",
  "testPathDirs": [
    "/home/cesar/demo"
  ],
  "testPathIgnorePatterns": [
    "/node_modules/"
  ],
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
  "testURL": "about:blank",
  "timers": "real",
  "transformIgnorePatterns": [
    "/node_modules/"
  ],
  "useStderr": false,
  "verbose": null,
  "watch": false,
  "cache": false,
  "watchman": true
}
Error: EACCES: permission denied, open '/tmp/jest/haste-map--home-cesar-demo-90020ade716ebf28b3b7c8845c128649'
    at Object.fs.openSync (fs.js:557:18)
    at Object.fs.writeFileSync (fs.js:1214:33)
    at HasteMap._persist (/home/cesar/demo/node_modules/jest-haste-map/build/index.js:414:8)
    at _buildPromise._buildFileMap.then.then.hasteMap (/home/cesar/demo/node_modules/jest-haste-map/build/index.js:245:14)
    at process._tickCallback (internal/process/next_tick.js:103:7)

I've fixed this issue by setting to /tmp the cacheDirectory in the package.json. I think it's the only solution when several users want to run Jest on the same machine. It could be the default setting.

Or it could append the username to the cacheDirectory like /tmp/jest-cesar, but it seems very strange.

@thymikee
Copy link
Collaborator

thymikee commented Dec 8, 2016

There's an idea to tackle it in #2231. We'll keep you posted.

@thymikee
Copy link
Collaborator

Aaaand it's closed (see #2303). Turns out cacheDirectory gives us all the flexibility to fight such issues. Thanks for your input!

@joshkel
Copy link
Contributor

joshkel commented Jan 23, 2017

Could I request that this be re-opened?

I don't understand how cacheDirectory fixes the problem, since it's either a relative directory (which can cause problems (?) and seems awkward) or a single shared absolute path (which goes back to the original problem of not being able to run Jest on a multi-user host). What am I missing?

Even if cacheDirectory does solve the problem, it seems quite silly that Jest requires manual reconfiguration to work on a multi-user system. (After all, "the Jest philosophy is to work great by default". 😃)

Including the UID in the default cache directory (e.g., path.join(os.tmpdir(), 'jest-' + process.getuid())) would be an easy fix.

@cpojer
Copy link
Member

cpojer commented Jan 23, 2017

If you'd like to send a PR to add the uid to the default cache paths including tests, I'm happy to accept that.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants