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 run fails when installed using yarn 3.x on apple silicon mac #27542

Closed
tchiaspko opened this issue Aug 13, 2023 · 24 comments
Closed

cypress run fails when installed using yarn 3.x on apple silicon mac #27542

tchiaspko opened this issue Aug 13, 2023 · 24 comments
Labels
package manager: yarn Issues relating to yarn

Comments

@tchiaspko
Copy link

Current behavior

Running cypress 12.x installed using yarn 3.x on Apple Silicon causes "Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound."


DevTools listening on ws://127.0.0.1:49377/devtools/browser/9349252f-b218-422b-96a8-333b9339c723
/private/tmp/cypress-example-kitchensink_yarn3x/.pnp.cjs:22522
      Error.captureStackTrace(firstError);
            ^

Error: Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @opentelemetry/resources
Required by: /Users/tonychia/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/packages/telemetry/dist/

Require stack:

Desired behavior

"yarn run cypress run" should not have any issue on "Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound" when installed using yarn 3.x on Apple Silicon Mac

Test code to reproduce

Yarn 1.22.x (working)

mkdir /tmp/cypress-example-kitchensink_yarn1x
cd /tmp/cypress-example-kitchensink_yarn1x
git clone https://github.com/cypress-io/cypress-example-kitchensink.git
cd cypress-example-kitchensink
verify yarn version is 1.22.x with yarn --version
yarn install
yarn run cypress run
You get " Running: 1-getting-started/todo.cy.js (1 of 20)"

Yarn 3.x (Not working)

mkdir /tmp/cypress-example-kitchensink_yarn3x
cd /tmp/cypress-example-kitchensink_yarn3x
git clone https://github.com/cypress-io/cypress-example-kitchensink.git
cd cypress-example-kitchensink
switch to yarn 3.x
yarn set version berry or
yarn set version 3.0.1
verify yarn version is 3.x with yarn --version
yarn install
yarn run cypress run
You get the following error message

Error: Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

cypress run output

yarn run cypress run
(node:14330) [MODULE_NOT_FOUND] Error: debug tried to access supports-color (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.
(Use node --trace-warnings ... to show where the warning was created)
[14331:0812/201925.935593:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[14331:0812/201925.935610:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[14331:0812/201925.935614:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[14331:0812/201925.935616:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.

DevTools listening on ws://127.0.0.1:49377/devtools/browser/9349252f-b218-422b-96a8-333b9339c723
/private/tmp/cypress-example-kitchensink_yarn3x/.pnp.cjs:22522
Error.captureStackTrace(firstError);
^

Error: Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @opentelemetry/resources
Required by: /Users/tonychia/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/packages/telemetry/dist/

Require stack:

  • /Users/tonychia/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/packages/telemetry/dist/node.js
  • /Users/tonychia/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/require_async_child.js
    at require$$0.Module._resolveFilename (/private/tmp/cypress-example-kitchensink_yarn3x/.pnp.cjs:22522:13)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at require$$0.Module._load (/private/tmp/cypress-example-kitchensink_yarn3x/.pnp.cjs:22411:31)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object. (/Users/tonychia/Library/Caches/Cypress/12.17.3/Cypress.app/Contents/Resources/app/packages/telemetry/dist/node.js:4:21)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at require$$0.Module._extensions..js (/private/tmp/cypress-example-kitchensink_yarn3x/.pnp.cjs:22566:33)
    at Module.load (node:internal/modules/cjs/loader:1091:32)

Cypress Version

12.17.3

Node version

v14.21.2, v18.7.0

Operating System

Mac OSX 13.4.1

Debug Logs

No response

Other

No response

@MikeMcC399
Copy link
Contributor

@tchiaspko

Do you still get the error message "Error: Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound." if you run Cypress under Yarn Modern with

yarn run local:run

instead of

yarn run cypress run?

What happens if you set up Yarn Modern for nodeLinker node-modules instead of the default pnp (Plug'n'Play). Do you still get the error message?

@tchiaspko
Copy link
Author

I still get the same error when running with "yarn run local:run"

However after I run "yarn config set nodeLinker node-modules", then either "yarn run local:run
" or "yarn run cypress" doesn't give any missing dependencies issue.

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Aug 13, 2023

@tchiaspko

Thanks for your test! So now we know that the issue occurs only on Yarn Modern (Version 3) in Plug'n'Play mode, which is the default mode for new installations. I tried to reproduce on a macos-13 GitHub-hosted runner and I didn't see the problem there.

The spec for the GitHub runner was

uname -a
Darwin Mac-1692023867696.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:21:56 PDT 2023; root:xnu-8796.141.3~6/RELEASE_X86_64 x86_64

so not Apple Silicon. (See Supported runners and hardware resources.)

Somebody with a Silicon macOS system (arm64) would need to cross-check.

Edit: Added the information that the GitHub runner was x86_64.

@jennifer-shehane jennifer-shehane added stage: needs investigating Someone from Cypress needs to look at this package manager: yarn Issues relating to yarn labels Dec 17, 2023
@daveoconnor
Copy link

I'm getting this on Ubuntu 22.04

@MikeMcC399
Copy link
Contributor

@daveoconnor

I'm getting this on Ubuntu 22.04

Do you have any more details:

  • hardware architecture?
  • version of Cypress?
  • version of Node.js?
  • local Ubuntu or remote Ubuntu with CI provider?
  • if local, is this Ubuntu native or in a virtual environment
  • if virtual, which one?
  • if CI provider, which one?
  • Package manager / Package manager version / Package manager options (if Yarn or pnpm)?
  • log file?

@daveoconnor
Copy link

Thanks Mike, let me know if there's any more info you need.

  • x86_64
  • Cypress 13.6.6.
  • node v21.7.0
  • local Ubuntu
  • Ubuntu native
  • Yarn 4.1.0
  • Logs from cypress run:
[4041417:0311/110139.880848:ERROR:node_bindings.cc(299)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[4041417:0311/110139.880892:ERROR:node_bindings.cc(299)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[4041417:0311/110139.880895:ERROR:node_bindings.cc(299)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[4041417:0311/110139.880898:ERROR:node_bindings.cc(299)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.

DevTools listening on ws://127.0.0.1:41987/devtools/browser/d0a877a8-8613-44fd-967f-c038f3451036
/home/{redacted}/work/{redacted}/.pnp.cjs:18807
      Error.captureStackTrace(firstError);
            ^

Error: Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @opentelemetry/resources
Required by: /home/{redacted}/.cache/Cypress/13.6.6/Cypress/resources/app/node_modules/@packages/telemetry/dist/

Require stack:
- /home/{redacted}/.cache/Cypress/13.6.6/Cypress/resources/app/node_modules/@packages/telemetry/dist/node.js
- /home/{redacted}/.cache/Cypress/13.6.6/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js
    at require$$0.Module._resolveFilename (/home/{redacted}/work/{redacted}/.pnp.cjs:18807:13)
    at Module._load (node:internal/modules/cjs/loader:983:27)
    at require$$0.Module._load (/home/{redacted}/work/{redacted}/.pnp.cjs:18698:31)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/home/{redacted}/.cache/Cypress/13.6.6/Cypress/resources/app/node_modules/@packages/telemetry/dist/node.js:4:21)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at require$$0.Module._extensions..js (/home/{redacted}/work/{redacted}/.pnp.cjs:18850:33)
    at Module.load (node:internal/modules/cjs/loader:1205:32)

Node.js v21.7.0

@MikeMcC399
Copy link
Contributor

@daveoconnor

Many thanks for your details! I wasn't able to reproduce this using the simple E2E / Electron command in an environment aimed to match your local Ubuntu environment:

yarn cypress run

What command did you run when this error occurred?

I assume from your logs that you are using Yarn Plug'n'Play and if you execute

yarn config get nodeLinker

it would show

pnp

Let me know if I got that wrong!

@daveoconnor
Copy link

I get these errors when I run yarn cypress run That's right, output is pnp and I''m trying to avoid using node_modules.

Might be relevant info that this is for a local install of cypress in the project, not a global install maybe?

@tyler-austin
Copy link

I am getting the error too. But have been for a long time and haven't had the time to look into it until today.

Hardware
Apple M1 Pro

macOs Sonoma
Version 14.3.1 (23D60)

❯ nvm --version
0.39.3

❯ node -v
v20.11.0

❯ yarn -v
4.0.2

Binary Caches: /Users/tyler.austin/Library/Caches/Cypress
Cypress Version: 12.17.1 (stable)
System Platform: darwin (23.3.0)
System Memory: 34.4 GB free 283 MB

❯ cypress install
Cypress 12.17.1 is installed in /Users/tyler.austin/Library/Caches/Cypress/12.17.1

❯ cypress verify
✔  Verified Cypress! /Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app
It looks like this is your first time using Cypress: 12.17.1

✔  Verified Cypress! /Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app

Opening Cypress...
[9490:0311/152333.165289:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[9490:0311/152333.165308:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[9490:0311/152333.165312:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.
[9490:0311/152333.165314:ERROR:node_bindings.cc(279)] Most NODE_OPTIONs are not supported in packaged apps. See documentation for more details.

DevTools listening on ws://127.0.0.1:64373/devtools/browser/b1923f1d-505d-46fa-b4f8-d4c3a484be1b
2024-03-11 15:23:33.384 Cypress[9490:571925] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
/Users/tyler.austin/Github/<root dir>/.pnp.cjs:107584
      Error.captureStackTrace(firstError);
            ^

Error: Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @opentelemetry/resources
Required by: /Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/telemetry/dist/

Require stack:
- /Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/telemetry/dist/node.js
- /Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/require_async_child.js
    at require$$0.Module._resolveFilename (/Users/tyler.austin/Github/<root dir>/.pnp.cjs:107584:13)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at require$$0.Module._load (/Users/tyler.austin/Github/<root dir>/.pnp.cjs:107475:31)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/telemetry/dist/node.js:4:21)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at require$$0.Module._extensions..js (/Users/tyler.austin/Github/<root dir>/.pnp.cjs:107627:33)
    at Module.load (node:internal/modules/cjs/loader:1207:32)

Node.js v20.11.0

This is my company's mono-repo so I cannot change the nodeLinker with a lot of push back.

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Mar 12, 2024

@daveoconnor / @tyler-austin

Many thanks for your inputs! The common theme is the error message similar to

Error: Your application tried to access @opentelemetry/resources, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @opentelemetry/resources
Required by: ~/.cache/Cypress/13.6.6/Cypress/resources/app/node_modules/@packages/telemetry/dist/

on Yarn Modern Plug'n'Play running Cypress E2E testing. This is a Yarn pnp Semantic erroring output and this points to it being a compatibility issue between Cypress and Yarn Plug'n'Play.

The error has been reported on different operating systems and different versions. I have however not been able to reproduce it myself and I am not seeing it under GitHub Actions.

You are welcome to cross-check using a simple E2E project from one of the Cypress example directories which is correctly configured for Yarn Modern Plug'n'Play:

git clone https://github.com/cypress-io/github-action
cd github-action/examples/yarn-modern-pnp
yarn
yarn test

The example produces no error when run on GitHub (see https://github.com/cypress-io/github-action/actions/workflows/example-yarn-modern-pnp.yml?query=branch%3Amaster) or if I run it locally under Ubuntu 22.04 or Window 11.

I also went back to the steps to reproduce in the original posting and I could not reproduce it using https://github.com/cypress-io/cypress-example-kitchensink either, although that repo is not ideal for testing against Yarn, since it is configured for npm usage, not for Yarn.

@MikeMcC399
Copy link
Contributor

In other similar non-reproducible situations the response from Yarn Modern was to check that you do not have a .pnp.cjs file (or yarn.lock, or package.json - files that shouldn't be there) in your home folder.

@tyler-austin
Copy link

All three files to include .pnp.cjs, yarn.lock and a package.json file are present in the root directory of my mono-repo. I am pretty sure they are supposed to be there.

@tyler-austin
Copy link

For some reason, I am the only dev on this project of 100s that is having this issue. Could it be a file permission issue in the Cypress cache? A browser plugin? Or the configuration I have between nvm, node, npm, yarn, and cypress?

@tyler-austin
Copy link

I was trying to run a script that was calling cypress open from the root of the mono-repo with yarn workspace <workspace-name> <script-name>

I just tried changing directory into my package's root folder inside the mono-repo and I was able to get cypress to open with cypress open. However when I try to run the tests in my package, it threw an Cypress configuration error
Error: Cannot find module 'cypress' with the following stack trace:

Error: Cannot find module 'cypress'
Require stack:
- /Users/tyler.austin/Github/<mono-repo root>/packages/<package root>/cypress.config.cjs
- /Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js
- /Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/require_async_child.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object. (/Users/tyler.austin/Github/<mono-repo root>/packages/<package root>/cypress.config.cjs:1:26)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at loadFile (/Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:89:14)
    at EventEmitter. (/Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:116:38)
    at EventEmitter.emit (node:events:518:28)
    at process. (/Users/tyler.austin/Library/Caches/Cypress/12.17.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:518:28)

Could this be due to cypress not knowing how to handle *.cjs?

@MikeMcC399
Copy link
Contributor

@tyler-austin

All three files to include .pnp.cjs, yarn.lock and a package.json file are present in the root directory of my mono-repo. I am pretty sure they are supposed to be there.

The reference to home folder meant your personal home folder, not the root folder of the repository.
Check with ls -al ~ for instance to make sure there are no files which shouldn't be there.

@MikeMcC399
Copy link
Contributor

@tyler-austin

For some reason, I am the only dev on this project of 100s that is having this issue. Could it be a file permission issue in the Cypress cache? A browser plugin? Or the configuration I have between nvm, node, npm, yarn, and cypress?

If you are the only dev with the issue, it does suggest that there is something wrong with your environment.

@MikeMcC399
Copy link
Contributor

@tyler-austin

You've raised another issue here, and if you think you've found a bug, then it would be better to open a new issue as it depends very much on how exactly your repo is set up, so you would need to provide more details or better still an example public repo which demonstrates your issue.

Could this be due to cypress not knowing how to handle *.cjs?

According to References > Configuration > Configuration File

Cypress additionally supports config files with .mjs or .cjs extensions.

So, no, this is not a general problem.

@tyler-austin
Copy link

I had a .pnp.cjs file in my ~/ directory. I deleted it and now cypress is working! Thank you!

@MikeMcC399
Copy link
Contributor

@tyler-austin

I had a .pnp.cjs file in my ~/ directory. I deleted it and now cypress is working! Thank you!

That is a great success! It's a really weird error message to receive for that misconfiguration error. I would not have thought of this root cause myself. I just found it in the Yarn issue list and thought it might apply.

@MikeMcC399
Copy link
Contributor

@tchiaspko

It's a long time ago since you submitted this issue. Is this still something that you are experiencing or has it been resolved?

I would tend to suggest closing this issue now, as it seems to be caused by user-side Yarn Plug'n'Play misconfiguration, not a bug in Cypress.

@daveoconnor
Copy link

daveoconnor commented Mar 12, 2024

I also had one in my ~/ and removing it moved me past this.
Might be useful if a check were to be added to warn people that this might cause issues.

Thanks for the help Mike!

@MikeMcC399
Copy link
Contributor

@daveoconnor

I also had one in my ~/ and removing it moved me past this. Might be useful if a check were to be added to warn people that this might cause issues.

Thanks for the help Mike!

Good to hear that the same fix helped you too!

I don't know if a check in Cypress for this issue would be the right place to put it. That could be the subject of a separate enhancement request anyway. Perhaps it would make more sense for Yarn Modern to do the checking or at least add the gotcha to their documentation?

@tchiaspko
Copy link
Author

It was a local cache issue. This issue can be resolved.

@MikeMcC399
Copy link
Contributor

@tchiaspko

It was a local cache issue. This issue can be resolved.

Thanks very much for the confirmation!

Since you are the Author, you can close your own issue using the button below 🔽 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package manager: yarn Issues relating to yarn
Projects
None yet
Development

No branches or pull requests

5 participants