jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.24k stars 6.46k forks source link

jest fails to work when temp dir is on a RAM drive (Windows) #7978

Open Mesqalito opened 5 years ago

Mesqalito commented 5 years ago

🐛 Bug Report

Jest fails on start with error Error: EISDIR: illegal operation on a directory, realpath 'B:\Temp' when windows temp dir is set on a RAM drive

Last working version

Worked in 23.6.0 Stopped working in 24.1.0

To Reproduce

  1. Follow the Getting Started guide and create a simple test suite
  2. Create RAM drive using ImDisk tool (B: in my case)
  3. Point windows temporary directory (%TEMP% env variable) to a directory on RAM drive (B:\Temp) (a reboot may be required)
  4. Open command line, go to where you created test suite and run npm run test

Actual behavior

I get an error like this:

Error: ENOENT: no such file or directory, realpath 'B:\Temp'
    at Function.realpathSync.native (fs.js:1514:3)
    at realpathSync (D:\Projects\***\node_modules\realpath-native\index.js:29:28)
    ...

Expected behavior

I expect jest to run tests.

Run npx envinfo --preset jest

  System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  Binaries:
    Node: 10.14.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.9.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.3.0 - C:\Program Files\nodejs\npm.CMD
bluelovers commented 5 years ago

same here

bluelovers commented 5 years ago

in v24 it error, but in v23 it work

i think need to check this


Error: EISDIR: illegal operation on a directory, realpath 'T:\TEMP'
    at Function.realpathSync.native (fs.js:1513:3)
    at realpathSync (\node_modules
\realpath-native\index.js:29:28)
    at getCacheDirectory (\node_mo
dules\jest-config\build\getCacheDirectory.js:53:32)
    at Object.<anonymous> (\node_m
odules\jest-config\build\Defaults.js:40:50)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:1
0)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19)
avgalon commented 4 years ago

Hi, I still have this problem. anyone plan to push 'bluelovers' pr?

heavenkiller2018 commented 4 years ago

yes, i have the same problem, anyone can give a hand?

Hocti commented 3 years ago

fs.realpathSync.native can't read ramdisk path. Here are the quick fix:

\node_modules\jest-util\build\tryRealpath.js

function tryRealpath(path) {
  try {
    if(path==='R:\\Temp'){ //your temp folder path
        return path;
    }
    path = _gracefulFs().realpathSync.native(path);
  } catch (error) {

but may be use "realpathSync" replace "realpathSync.native" can solve it too, but it may make some new problem...

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

tophf commented 2 years ago

This can be fixed probably by reusing #6925 which solved the same problem in a different place.