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

cypress caching hangs in Gitlab CI in combination with Yarn 2 (berry) #23313

Closed
iomedico-beyer opened this issue Aug 12, 2022 · 5 comments
Closed

Comments

@iomedico-beyer
Copy link

Current behavior

After specifying CYPRESS_CACHE_FOLDER, our CI pipeline shows an Error and then hangs.

Desired behavior

Should not hang.

Test code to reproduce

?

Cypress Version

10.4.0

Node version

note sure

Operating System

note sure

Debug Logs

/builds/.../.pnp.cjs:31839
      Error.captureStackTrace(firstError);
            ^
Error: Your application tried to access lodash, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.
Required package: lodash
Required by: /builds/.../cache/Cypress/10.4.0/Cypress/resources/app/node_modules/@packages/server/lib/util/
Require stack:
- /builds/.../cache/Cypress/10.4.0/Cypress/resources/app/node_modules/@packages/server/lib/util/suppress_warnings.js
- /builds/.../cache/Cypress/10.4.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js
    at Function.require$$0.Module._resolveFilename (/builds/.../.pnp.cjs:31839:13)
    at Function.require$$0.Module._load (/builds/.../.pnp.cjs:31693:42)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/builds/.../cache/Cypress/10.4.0/Cypress/resources/app/node_modules/@packages/server/lib/util/suppress_warnings.js:1:11)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Object.require$$0.Module._extensions..js (/builds/.../.pnp.cjs:31883:33)
    at Module.load (node:internal/modules/cjs/loader:[98](https://...)1:32)
    at Function.require$$0.Module._load (/builds/.../.pnp.cjs:31723:14)

Other

Maybe relevant: We are using Yarn 2 (berry).

@nagash77
Copy link
Contributor

@iomedico-beyer Unfortunately at this point we have some known issues with yarn 2. We have this issue #22895 currently open which you can follow along which when addressed should fix your issue. In the meantime can you use yarn 1 and see if that works as a workaround?

@iomedico-beyer
Copy link
Author

In the meantime can you use yarn 1 and see if that works as a workaround?

No way. Yarn 2 reduced our CI pipeline time from 3 hours to 15 minutes. I guess this is because with Yarn 2 our CI doesn’t have to handle hundreds of thousands of files (from installed dependencies) anymore, but just hundreds (one for each dependency).

We will just keep Cypress caching off. But thanks anyway.

@pondchamp
Copy link

pondchamp commented Dec 17, 2022

Resurrecting this thread since I encountered this same issue with GitHub Actions - I've adjusted the CYPRESS_CACHE_FOLDER env var on my CI/CD pipeline to ensure it gets packaged/restored in my GitHub workspace (rather than in the user home directory) for later use, but doing so produced the same error you've described.

After doing some investigating starting at the lodash package being missing as a first clue, I ended up finding that there were a bunch of missing packages required to run cypress when just restoring from the cache, all of which were contained in this file: https://github.com/cypress-io/cypress/blob/develop/packages/server/package.json

The long-term solution is for the dev term to add the packages in this package file to the Cypress cache and reference the packages from there, but as a workaround, you can add the essential dev dependencies using this command (This is the list that works for me for Cypress 10.7.0, but YMMV on your environment):

yarn add --dev lodash debug graceful-fs bluebird [email protected] [email protected] [email protected] [email protected] [email protected] dayjs@^1.9.3 @cypress/webpack-batteries-included-preprocessor @cypress/webpack-preprocessor webpack@^4.44.2

Hope this works for you too!

@iomedico-beyer
Copy link
Author

@pondchamp Good to know! But I think I rather keep caching off than poluting my package.json. In JSON I can’t even add comments … Yuck! Why would anyone choose JSON as a configuration file format? I really don’t get it.

@prarie
Copy link

prarie commented Sep 1, 2023

I found this issue because I had the same error message. Not suggesting that my issue was the original poster's, but maybe others will end up here like I did.

In my case, it turned out that I had a .pnp.cjs file in my home folder that messed up the resolution, but in a way that wasn't clear and only appeared to affect running yarn cypress open. I suppose I must have run yarn install in my home directory without realizing at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants