[Bug?]: Yarn Berry does not support bash/shell scripts as bin
aries - unlike Yarn Classic, NPM, and PNPM
#6668
Labels
bug
Something isn't working
Self-service
Describe the bug
Hey folks,
I'm in the middle of upgrading some repos at work from Yarn Classic (1.x) to Yarn Berry (I've tested this with both the latest 3.x and 4.x)
We have some internal packages that expose "binaries" (via
package.json > bin
section) that are actually shell scripts. Some sanity checklist notes:#!/bin/bash
or#!/usr/bin/env bash
)chmod +x
)yarn bin {bin-name}
correctly outputs the path to the actual script. To that effect, callingyarn bin {bin-name} | bash
correctly executes the script correctly.In Yarn Classic (1.x), NPM (v9 and v10), PNPM (v9 and v10), I'm able to invoke these shell-script binaries like so, respectively:
yarn {bin-name}
npc {bin-name}
ppm {bin-name}
I get the expected output. Cool.
In Yarn Berry (tested v3.x and v4.x), however, invoking the binary via
yarn {bin-name}
will yield a syntax error because it attempts to parse the binary as if were a JavaScript file.I couldn't find documentation calling out this breaking change and justification is to why Yarn Berry would stop supporting shell-script based binaries when all other package managers support them.
There's an argument to be made that shell scripts aren't going to be as portable as JS-based files and all binaries should be either actual binaries or JS files but I think that's a separate discussion to the problem at hand.
To reproduce
Expected: ==>
Hello World
Actual:
Environment
Additional context
No response
The text was updated successfully, but these errors were encountered: