Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn against colons in directories when running user-defined scripts #7373

Open
foucdeg opened this issue Jul 6, 2019 · 3 comments
Open

Comments

@foucdeg
Copy link

foucdeg commented Jul 6, 2019

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 local node_modules/.bin directory.

Please mention your node.js, yarn and operating system version.
node 10.15.0, yarn 1.16, macOS 10.14.5

Related : #3515

@foucdeg foucdeg changed the title Warn against colons in directories when Warn against colons in directories when running user defined scripts Jul 6, 2019
@foucdeg foucdeg changed the title Warn against colons in directories when running user defined scripts Warn against colons in directories when running user-defined scripts Jul 6, 2019
@chrisdothtml
Copy link

+1 to providing a warning as it's not at all clear to the user why the command doesn't work in this case

@kantord
Copy link

kantord commented Nov 23, 2020

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.

@YodaLightsabr
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants