Skip to content

Globally installed binaries do not work in PowerShell after 1.13.0 #6902

@ArcanoxDragon

Description

@ArcanoxDragon

Since the 1.13.0 update, globally installed binaries do not work in PowerShell. The offending commit is 5419606, which is the update to the cmd-shim package. The version of cmd-shim that yarn updated to added default support for PowerShell, meaning that every binary writes a .ps1 shim in addition to the non-extension and the .cmd ones. It appears Yarn is first calling cmdShim during the "Linking Dependencies" phase to create the initial bin shims for the package. This is fine and dandy here, but later in the install step (after the success Installed <package> with binaries message is printed), Yarn calls cmdShim again once per binary, which causes cmdShim to write a shim for each of the shims. This results in files like binary.cmd.ps1, binary.ps1.ps1, etc, because cmd-shim thinks that the base name of the binary is actually binary.ps1. This causes the bash shim to be written to binary.cmd and binary.ps1, breaking those two shims (PowerShell finds the ps1 file which is actually a bash script). Here's a visual after yarn global add ts-node:

image

I added a console.trace to cmdShim in my local copy of Yarn to print out the arguments passed, and this is the output:

https://gist.github.com/briman0094/d7f256d1158d6e8f96afbb74e85840bb

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions