cypress: Error: EINVAL: invalid argument, mkdir on windows for cypress + windows + Angular project

Current behavior:

When cypres@3.8.3 is run on windows in Angular project, i am getting this type of error when i click on any test specs and try to run and capture image snapshot: Error: EINVAL: invalid argument, mkdir 'C:\Users\rocks\AppData\Roaming\Cypress\cy\production\projects\styleguide-e2e-a8ba09f50d81ec188e3b12528503dca9\bundles\C:\Users\rocks\project\torque\styleguide\cypress\support

Cypress cache folder is: C:\Users\rocks\AppData\Roaming\Cypress\cy\production\projects for windows.

Error1 Error2

Desired behavior:

It should not throw any error on windows system.

Test code to reproduce

Package.json

{
"cypress": "3.8.3",
"cypress-axe": "^0.8.1",
"cypress-cucumber-preprocessor": "^2.0.1",
"cypress-image-snapshot": "^3.1.1",
}

NPM command to open cypress:

npm run nx-high-memory -- e2e styleguide-e2e --watch
```
cypress.json config file
```json
{
  "video": false,
  "testFiles": "**/*.{feature,features}",
  "fixturesFolder": "../../cypress/fixtures",
  "integrationFolder": "../../cypress/integration",
  "pluginsFile": "../../cypress/plugins/index",
  "supportFile": "../../cypress/support/index",
  "screenshotsFolder": "../../cypress/screenshots"
}
```

### Versions

```json
"cypress": "3.8.3",
"cypress-axe": "^0.8.1",
"cypress-cucumber-preprocessor": "^2.0.1",
"cypress-image-snapshot": "^3.1.1",
"chrome": "Version 85.0.4183.102 (Official Build) (64-bit)"
"windows": 10
```

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 41 (10 by maintainers)

Most upvoted comments

I am able to reproduce this by setting a relative supportFile path in config

We found a workaround for this issue:

Create nested/cypressSupportForWindows.js file with content:

import '../support/index';

and then change nested/cypress.json to point that file

“supportFile”: “cypressSupportForWindows.js”,

Seems that this binary file you provided fixes the issue on our end. Thanks!

Can be reproduced with the following repo: https://github.com/ausi/cypress-issue-8599

git clone git@github.com:ausi/cypress-issue-8599.git
cd cypress-issue-8599
cd subdirectory
npm install
npx cypress run

This results in the following output (only on Windows):

Oops...we found an error preparing this test file:

  > ..\support.js

The error was:

Error: EINVAL: invalid argument, mkdir 'C:\Users\████\AppData\Roaming\Cypress\cy\production\projects\subdirectory-8d97a5303e393e4931bd1dd983377a82\bundles\C:\Users\████\Desktop\cypress-issue-8599'

I’m starting to take a look into this issues. Just some updates since this is a pretty old issue.

I am still exploring solutions, but I am leaning towards making parent files bundle to the root of the bundle directory so the preprocessor can output correctly to a path. Collisions could be possible, but I think they are highly unlikely.

I suspect that you’d have to use the headless mode only. You wouldn’t be able to use Cypress in the windows mode.

I tried configuring X.Org once and using an X-Server on Windows. Not with Cypress, but with Chrome and VS Code. The convenience of the work was a lot worse than with the native Windows applications.

Since WSL2 was released, the performance of the filesystem has improved and the remote features too. But not UI. WSL wasn’t designed for running UI applications.

I will help you fix this but trying to reproduce the issue based on snippets and comments is a bit time consuming, can you please upload a repo I can clone and reproduce the issue? That will let me spend more time finding a fix. Thanks!

I think that this problem can be reproduced on any platform. I reproduced it on ~Linux, Mac and~ Windows, as I wrote above.

If you decide to maintain dependencies and configuration of your E2E tests separate from your build directory, you will face the bug described by this issue.

A workaround: create a symlink to the test and source files inside the Cypress directory, and use the symlink in the Cypress configuration. Cypress will see everything apparently inside its directory and will work well.

src/...      sources and e2e tests
cypress/...  cypress config, support, plugins

cypress/src --> ../src symbolic link

EDITED: The problem occurs only on Windows.

I am able to reproduce this by setting a relative supportFile path in config

Setup Reproduction project: https://github.com/artkoselev/cypress8599 OS: Windows Cypress package version: 6.2.1 Cypress binary version: 6.2.1 Electron version: 11.1.1 Bundled Node version: 12.18.3

Reproduction steps

  1. Clone repository
  2. call npm install
  3. call npm test

Expected: Cypress visits cypress.io page Actual: Error thrown - Error: EINVAL: invalid argument, mkdir 'C:\Users\{user}\AppData\Roaming\Cypress\cy\production\projects\nested-0b20f090537cddae1cfb3da2204e4eae\bundles\C:\Users\{user}\cypress8599\support

Notes: npm test calls npx cypress run --project nested and nested project contains entry "supportFile": "../support/index.js". From the error message it seems that the path gets converted to absolute which results in an invalid argument for ‘mkdir’ - ... bundles\C:\Users\{user}\ ...