Skip to content

Yarn run doesn't find bin scripts when using Plug and Play on Windows #6493

@edmorley

Description

@edmorley

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
yarn run fails to find packages' bin scripts when using plug and play mode on Windows, instead giving:

C:\Users\Ed\src\testcase-yarn-pnp-windows>yarn lint
yarn run v1.12.0
warning package.json: No license field
$ eslint --version
'eslint' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

If the current behavior is a bug, please provide the steps to reproduce.

  1. Create an empty directory containing this package.json:
{
  "installConfig": {
    "pnp": true
  },
  "dependencies": {
    "eslint": "^5.6.1"
  },
  "scripts": {
    "lint": "eslint --version"
  }
}
  1. yarn --pnp
  2. yarn lint

What is the expected behavior?
ESLint is found and outputs its version.

Please mention your node.js, yarn and operating system version.
Yarn 1.12.0, Node 10.11.0, Windows 10 x64

Other:

  • This reproduced for me inside both an MSYS2 bash shell and when using native cmd.exe
  • The same error occurred using something other than eslint (eg jest)
  • If instead of running yarn lint, I call the package directly (ie not a scripts command), I get a more informative error message:
yarn eslint --version
yarn run v1.12.0
warning package.json: No license field
$ C:\Users\Ed\AppData\Local\Yarn\Cache\v3\npm-eslint-5.6.1-348134e32ccc09abb2df1bf282b3f6eed8c7b480\node_modules\eslint\.bin\eslint --version
'C:\Users\Ed\AppData\Local\Yarn\Cache\v3\npm-eslint-5.6.1-348134e32ccc09abb2df1bf282b3f6eed8c7b480\node_modules\eslint\.bin\eslint'
is not recognized as an internal or external command, operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
01/10/2018  17:11    <JUNCTION>     eslint [C:\Users\Ed\AppData\Local\Yarn\Cache\v3\npm-eslint-5.6.1-348134e32ccc09abb2df1bf282b3f6eed8c7b480\node_modules\eslint\bin\eslint.js]
  • Trying to open the junction in Windows Explorer gives:
C:\Users\Ed\AppData\Local\Yarn\Cache\v3\npm-eslint-5.6.1-348134e32ccc09abb2df...\eslint
is not accessible.

The directory name is invalid.
  • MSYS2 reports it as a symlink to a non-existent directory rather than a file (note the trailing slash):
lrwxrwxrwx 1 Ed None 132 Oct  1 17:11 eslint -> /c/Users/Ed/AppData/Local/Yarn/Cache/v3/npm-eslint-5.6.1-348134e32ccc09abb2df1bf282b3f6eed8c7b480/node_modules/eslint/bin/eslint.js/

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions