Warn against colons in directories when running user-defined scripts
Do you want to request a feature or report a bug? A feature (a warning)
What is the current behavior?
package.json:
{
...
"dependencies": {
"some-command": "latest"
},
"scripts": {
"build": "some-command"
}
}
cd /directory:name:with:colons/
yarn run build
Returns error: some-command: command not found
This is because yarn appends the full path to node_modules/.bin to the $PATH before running the script, in order for some-command to work. But in this case, the full path contains colons, which ends up breaking the system's parsing of the $PATH. The system silently skips the invalid parts of $PATH and some-command cannot be found.
What is the expected behavior?
First I looked up the way to escape a colon in $PATH, but it cannot be done.
So I suggest that yarn emits a warning before it attemps to run a user-defined script in a directory that contains colons. Such as:
Warning: the path to the current directory contains colons (
:). This may break user-defined scripts that use a command from the localnode_modules/.bindirectory.
Please mention your node.js, yarn and operating system version. node 10.15.0, yarn 1.16, macOS 10.14.5
Related : https://github.com/yarnpkg/yarn/issues/3515
+1 to providing a warning as it's not at all clear to the user why the command doesn't work in this case
I would say it would be better if yarn refused to run in such a path altogether, as some core functionality will be completely broken in most real life situations.
This would be really nice to have! I just ran into this problem and I think it would save other people, mostly inexperienced yarn users, a lot of time.