berry: [Bug] cypress fails install with node-modules linker

  • I’d be willing to implement a fix

Describe the bug

Running yarn install in a project depending on cypress and using nodeLinker: "node-modules" fails with ➤ YN0009: │ cypress@npm:3.8.3 couldn't be built successfully (exit code 1, logs can be found here: /tmp/logfile-394W9pExI466nwo.log).

And it also hangs on the first install but that is already reported in https://github.com/yarnpkg/berry/issues/751

Apparently yarn thinks cypress requires an undeclared dependency minimist (used in postinstall) though this dependency is declared.

/tmp/logfile-394W9pExI466nwo.log
# This file contains the result of Yarn building a package (cypress@npm:3.8.2)
# Script name: postinstall

/home/eps1lon/Development/src/js/dom-accessibility-api/.pnp.js:23819
    throw firstError;
    ^

Error: Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies

Required package: minimist (via "minimist")
Required by: /home/eps1lon/Development/src/js/dom-accessibility-api/node_modules/cypress/

Require stack:
- /home/eps1lon/Development/src/js/dom-accessibility-api/node_modules/cypress/index.js
    at Object.makeError (/home/eps1lon/Development/src/js/dom-accessibility-api/.pnp.js:15564:24)
    at resolveToUnqualified (/home/eps1lon/Development/src/js/dom-accessibility-api/.pnp.js:24420:35)
    at resolveRequest (/home/eps1lon/Development/src/js/dom-accessibility-api/.pnp.js:24504:27)
    at Object.resolveRequest (/home/eps1lon/Development/src/js/dom-accessibility-api/.pnp.js:24572:26)
    at Function.module_1.Module._resolveFilename (/home/eps1lon/Development/src/js/dom-accessibility-api/.pnp.js:23802:34)
    at Function.module_1.Module._load (/home/eps1lon/Development/src/js/dom-accessibility-api/.pnp.js:23687:40)
    at Module.require (internal/modules/cjs/loader.js:838:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/eps1lon/Development/src/js/dom-accessibility-api/node_modules/cypress/index.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:945:30) {
  code: 'MODULE_NOT_FOUND',
  pnpCode: 'UNDECLARED_DEPENDENCY',
  data: {
    request: 'minimist',
    issuer: '/home/eps1lon/Development/src/js/dom-accessibility-api/node_modules/cypress/',
    dependencyName: 'minimist'
  },
  requireStack: [
    '/home/eps1lon/Development/src/js/dom-accessibility-api/node_modules/cypress/index.js'
  ]
}

To Reproduce

await yarn(`init`);
await yarn(`add`, `cypress`);
await yarn(`config`, `set`, `nodeLinker`, `node-modules`);

await expect(yarn(`install`)).resolves.toBeTruthy();

Environment if relevant (please complete the following information):

  • OS: Ubuntu 18.04.3 LTS
  • Node version: v12.11.1
  • Yarn version: 2.0.0-rc.27

Additional context

Switching to node_modules because of https://github.com/prettier/prettier-vscode/issues/1221

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

That should do it. Even includes the full log. Very nice.

Error: Command failed: /home/eps1lon/.nvm/versions/node/v10.16.3/bin/node /home/eps1lon/Development/src/js/forks/berry/scripts/actions/../run-yarn.js install

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0.03s
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0.17s
➤ YN0000: ┌ Link step
➤ YN0007: │ cypress@npm:3.8.3 must be built because it never did before or the last one failed
➤ YN0000: │ cypress@npm:3.8.3 STDERR /tmp/tmp-16064MWTMwpKFCA6T/.pnp.js:15510
➤ YN0000: │ cypress@npm:3.8.3 STDERR     throw firstError;
➤ YN0000: │ cypress@npm:3.8.3 STDERR     ^
➤ YN0000: │ cypress@npm:3.8.3 STDERR 
➤ YN0000: │ cypress@npm:3.8.3 STDERR Error: Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies
➤ YN0000: │ cypress@npm:3.8.3 STDERR 
➤ YN0000: │ cypress@npm:3.8.3 STDERR Required package: minimist (via "minimist")
➤ YN0000: │ cypress@npm:3.8.3 STDERR Required by: /tmp/tmp-16064MWTMwpKFCA6T/node_modules/cypress/
➤ YN0000: │ cypress@npm:3.8.3 STDERR 
➤ YN0000: │ cypress@npm:3.8.3 STDERR Require stack:
➤ YN0000: │ cypress@npm:3.8.3 STDERR - /tmp/tmp-16064MWTMwpKFCA6T/node_modules/cypress/index.js
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at Object.makeError (/tmp/tmp-16064MWTMwpKFCA6T/.pnp.js:7255:24)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at resolveToUnqualified (/tmp/tmp-16064MWTMwpKFCA6T/.pnp.js:16111:35)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at resolveRequest (/tmp/tmp-16064MWTMwpKFCA6T/.pnp.js:16195:27)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at Object.resolveRequest.maybeLog [as resolveRequest] (/tmp/tmp-16064MWTMwpKFCA6T/.pnp.js:16263:26)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at Function.module_1.Module._resolveFilename (/tmp/tmp-16064MWTMwpKFCA6T/.pnp.js:15493:34)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at Function.module_1.Module._load (/tmp/tmp-16064MWTMwpKFCA6T/.pnp.js:15378:40)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at Module.require (internal/modules/cjs/loader.js:692:17)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at require (internal/modules/cjs/helpers.js:25:18)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at Object.<anonymous> (/tmp/tmp-16064MWTMwpKFCA6T/node_modules/cypress/index.js:3:16)
➤ YN0000: │ cypress@npm:3.8.3 STDERR     at Module._compile (internal/modules/cjs/loader.js:778:30)
➤ YN0009: │ cypress@npm:3.8.3 couldn't be built successfully (exit code 1, logs can be found here: /tmp/logfile-1722786XLXW0Mh6G2.log)
➤ YN0000: └ Completed in 7.58s
➤ YN0000: Failed with errors in 7.8s

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)⏎   

@eps1lon an await was missing, hence the passing yarnbot even though it should have fail. @larixer try running yarn sherlock 754 in the repo, it should throw the error.

Ok the arrange and act part I got. No idea how the assertion should look to be considered “reproducible”.

Either way I don’t have more time. Hope this is sufficient.