Describe the bug
Yarn 2.0 fails with a SyntaxError when running a bin file that isn't authored in JS. For example, the bin file may be an executable file with a shebang #!/usr/bin/env sh.
Example bin file:
#!/usr/bin/env sh
echo 'Hello world!'
To Reproduce
See sample package (@cameronhunter/berry-bin-bug) that defines a bin that is an executable file with a shebang.
const { promises: { writeFile, chmod } } = require('fs');
await writeFile('./hello-world', '#!/usr/bin/env sh\necho "Hello world!"');
await chmod('./hello-world', 0o765);
await packageJsonAndInstall({
bin: { 'hello-world': './hello-world' }
});
await expect(yarn('hello-world')).resolves.toContain('Hello world!');
Example of failure:
$ yarn berry-bin-bug
/Users/chunter/workspace/github/cameronhunter/berry-bin-bug/bin/berry-bin-bug:3
echo "Hello world!"
^^^^^^^^^^^^^^
SyntaxError: Unexpected string
at Module._compile (internal/modules/cjs/loader.js:895:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.module_1.Module._load (/Users/chunter/workspace/github/cameronhunter/berry-bin-bug/.pnp.js:13519:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
Environment if relevant (please complete the following information):
- OS: MacOS Mojave (
10.14.5)
- Node version:
12.14.0
- Yarn version:
2.0.0-rc.28
Describe the bug
Yarn 2.0 fails with a
SyntaxErrorwhen running abinfile that isn't authored in JS. For example, the bin file may be an executable file with a shebang#!/usr/bin/env sh.Example
binfile:To Reproduce
See sample package (
@cameronhunter/berry-bin-bug) that defines abinthat is an executable file with a shebang.Example of failure:
Environment if relevant (please complete the following information):
10.14.5)12.14.02.0.0-rc.28