jest icon indicating copy to clipboard operation
jest copied to clipboard

Error when running Jest: EISDIR: illegal operation on a directory

Open betfix opened this issue 4 years ago • 5 comments

🐛 Bug Report

Jest throws an error:

Error: EISDIR: illegal operation on a directory, realpath 'Z:\Temp'
    at Function.realpathSync.native (fs.js:1588:3)
    at tryRealpath (D:\myproject\node_modules\jest-util\build\tryRealpath.js:26:39)
    at getCacheDirectory (D:myproject\node_modules\jest-config\build\getCacheDirectory.js:89:33)

The error disappears after going to node_modules\jest-config\build\Defaults.js and replacing line: cacheDirectory: (0, _getCacheDirectory.default)(), with: cacheDirectory: 'Z:\\temp',

To Reproduce

  • Download ImDisk Toolkit for Windows (or perhaps other RAM disk tool), make a RAM disk (e.g. Z) and set Windows %TEMP% and %TMP% environment variables to a directory on this disk (e.g. Z:\temp)
  • Create a node project, install Jest and try to run a Jest test

Expected behavior

Jest should run a test.

Link to repl or repo (highly encouraged)

https://github.com/betfix/temp-jest-error

envinfo

  System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz
  Binaries:
    Node: 12.13.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.17.3 - D:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.12.0 - D:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: ^26.6.3 => 26.6.3

betfix avatar Mar 01 '21 12:03 betfix

I have the same issue on my system. Project created with create-react-app and a Ramdisk with environment variables set by ImDisk as such:

TEMP=R:\Temp
TMP=R:\Temp

git-commit avatar Mar 08 '22 15:03 git-commit

I don't have access to a windows machine, so can't really do anything here. But swallowing EISDIR in https://github.com/facebook/jest/blob/54420eb51baecaba7dff293770f8cb2579825731/packages/jest-util/src/tryRealpath.ts#L14-L16 seems reasonable? Can you test it?

SimenB avatar Mar 09 '22 07:03 SimenB

@SimenB, yes, your idea works e.g. if (error.code !== 'ENOENT' && error.code !== 'EISDIR') {

tophf avatar Aug 07 '22 06:08 tophf

great, wanna send a PR?

SimenB avatar Aug 07 '22 13:08 SimenB

Probably not as I feel kinda intimidated by the amount of steps in PR guide as well as the need for CLA. Not soon'ish anyway.

tophf avatar Aug 07 '22 13:08 tophf

#13157

SimenB avatar Aug 22 '22 07:08 SimenB

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[bot] avatar Sep 22 '22 00:09 github-actions[bot]