Berry: [Bug] yarn pnpify fails with space character in path

Created on 3 Mar 2020  路  5Comments  路  Source: yarnpkg/berry

  • [ ] I'd be willing to implement a fix

Describe the bug

yarn pnpify fails when there is a space in the path:

C:\akrawitz\Research - Test\mypackage>yarn pnpify remark README.md
C:\akrawitz\Research - Test\mypackage\.pnp.js:32402
    throw firstError;
    ^

Error: Couldn't find a suitable Node resolution for the specified unqualified path

Source path: /C:/akrawitz/Research
Rejected resolution: /C:/akrawitz/Research
Rejected resolution: /C:/akrawitz/Research.js
Rejected resolution: /C:/akrawitz/Research.json
Rejected resolution: /C:/akrawitz/Research.node

Require stack:
- internal/preload
    at Object.makeError (C:\akrawitz\Research - Test\mypackage\.pnp.js:24113:24)
    at resolveUnqualified (C:\akrawitz\Research - Test\mypackage\.pnp.js:33069:29)
    at resolveRequest (C:\akrawitz\Research - Test\mypackage\.pnp.js:33094:14)
    at Object.resolveRequest (C:\akrawitz\Research - Test\mypackage\.pnp.js:33156:26)
    at Function.module_1.Module._resolveFilename (C:\akrawitz\Research - Test\mypackage\.pnp.js:32385:34)
    at Function.module_1.Module._load (C:\akrawitz\Research - Test\mypackage\.pnp.js:32270:40)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1296:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:448:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:71:3) {
  code: 'MODULE_NOT_FOUND',
  pnpCode: 'QUALIFIED_PATH_RESOLUTION_FAILED',
  data: {
    unqualifiedPath: '/C:/akrawitz/Research',
    request: '/C:/akrawitz/Research',
    issuer: '/C:/akrawitz/Research - Test/mypackage/'
  },
  requireStack: [ 'internal/preload' ]
}

C:\akrawitz\Research - Test\mypackage>                                                             

To Reproduce

Run yarn pnpify in a package when there is a space in the name of one of the containing directories. Note that the troublesome directory name is _outside_ of the package.

Environment if relevant (please complete the following information):

  • OS: Windows 10
  • Node version: 13.9.0
  • Yarn version: 2.0.0-rc.29

Additional context

For better or worse, spaces are common in Windows directory names (e.g. 'Program Files').

bug

All 5 comments

I encounter the same issue - it happens to any script running command

C:\Users\Regev Brody\WebstormProjects\node-upgrade-checker>yarn run lint
C:\Users\Regev Brody\WebstormProjects\node-upgrade-checker\.pnp.js:20735
    throw firstError;
    ^

Error: Qualified path resolution failed - none of the candidates can be found on the disk.

Source path: /C:/Users/Regev
Rejected candidate: /C:/Users/Regev
Rejected candidate: /C:/Users/Regev.js
Rejected candidate: /C:/Users/Regev.json
Rejected candidate: /C:/Users/Regev.node

    at Object.makeError (C:\Users\Regev Brody\WebstormProjects\node-upgrade-checker\.pnp.js:14007:34)
    at resolveUnqualified (C:\Users\Regev Brody\WebstormProjects\node-upgrade-checker\.pnp.js:21438:29)
    at resolveRequest (C:\Users\Regev Brody\WebstormProjects\node-upgrade-checker\.pnp.js:21463:14)
    at Object.resolveRequest (C:\Users\Regev Brody\WebstormProjects\node-upgrade-checker\.pnp.js:21525:26)
    at Function.module_1.Module._resolveFilename (C:\Users\Regev Brody\WebstormProjects\node-upgrade-checker\.pnp.js:20713:34)
    at Function.module_1.Module._load (C:\Users\Regev Brody\WebstormProjects\node-upgrade-checker\.pnp.js:20598:40)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47

@akrawitz @regevbr Please provide exact reproduction steps.

@larixer it took me a while to reproduce until I realized that it only happens if your are issuing a command that uses yarn run in it.

reproduce steps (on windows)

  • Create a directory with space in it and cd to it
  • install yarn 2 from sources and run yarn init
  • Add the following scripts to package.json:
  "scripts": {
    "foo2": "yarn run foo",
    "foo": "node -e 'console.log(1)'"
  }
  • run yarn run foo and it works
  • run yarn run foo2 and it fails (see logs below)
C:\WebstormProjects\test 1>yarn -v
2.0.0-rc.31.git.20200416.8e570cbe

C:\WebstormProjects\test 1>yarn run foo
1

C:\WebstormProjects\test 1>yarn run foo2
C:\WebstormProjects\test 1\.pnp.js:9275
    throw firstError;
    ^

Error: Qualified path resolution failed - none of the candidates can be found on the disk.

Source path: /C:/WebstormProjects/test
Rejected candidate: /C:/WebstormProjects/test
Rejected candidate: /C:/WebstormProjects/test.js
Rejected candidate: /C:/WebstormProjects/test.json
Rejected candidate: /C:/WebstormProjects/test.node

    at Object.makeError (C:\WebstormProjects\test 1\.pnp.js:2540:34)
    at resolveUnqualified (C:\WebstormProjects\test 1\.pnp.js:9971:29)
    at resolveRequest (C:\WebstormProjects\test 1\.pnp.js:9996:14)
    at Object.resolveRequest (C:\WebstormProjects\test 1\.pnp.js:10058:26)
    at Function.module_1.Module._resolveFilename (C:\WebstormProjects\test 1\.pnp.js:9253:34)
    at Function.module_1.Module._load (C:\WebstormProjects\test 1\.pnp.js:9138:40)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47

I can confirm that the issue does not happen on linux.

@regevbr Thanks for the steps, I can reproduce it now. Seems it has nothing to do with pnpify tool though. Looking...

Opened PR with the fix: #1211

Was this page helpful?
0 / 5 - 0 ratings