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

[BUG] git is unable to add 'git-core' to the PATH when it is run using npm scripts #1487

Closed
Shayan-To opened this issue Jul 3, 2020 · 1 comment · May be fixed by Jankyboy/cli-1#5 or baby636/cli#1
Labels
Bug thing that needs fixing Release 6.x work is associated with a specific npm 6 release

Comments

@Shayan-To
Copy link

What / Why

I'm running Windows 10 build 19041, npm version 6.14.4, and git version 2.27.0.windows.1.

When I run git submodule, it works as expected and exits without error. But when I create an npm script in my package.json like this:

"scripts": {
    "sth": "git submodule"
}

And try to run it like npm run sth, it gives me this error:

> test-project@0.1.0 sth D:\...\test-project
> git submodule

D:/Program_Files/Git/mingw64/libexec/git-core\git-submodule: line 22: .: git-sh-setup: file not found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-project@0.1.0 sth: `git submodule`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-project@0.1.0 sth script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\.....

When

  • n/a

Where

  • n/a

How

When git is run from an npm script, it cannot add the git-core path to the PATH environment variable, and it fails to execute its bash scripts.

Current Behavior

When I run git submodule normally, this is prepended to the PATH:

/mingw64/libexec/git-core

But when I run it from within an npm script, this is instead prepended:

/d/Program_Files/nodejs/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/d/Shayan/MyDocuments/Coding/SampleProject/node_modules/.bin

(I got this info by adding a line (echo "$PATH") to my git-submodule script in git's installation directory.)

Steps to Reproduce

Add a script like "sth": "git submodule" to your package.json and run it like npm run sth.

Expected Behavior

When I run git submodule from within an npm script, git-core path is also prepended in addition to npm-related paths. I expect my PATH environment variable to look like this:

/mingw64/libexec/git-core:/d/Program_Files/nodejs/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/d/Shayan/MyDocuments/Coding/SampleProject/node_modules/.bin

Who

  • n/a

References

  • n/a
@Shayan-To Shayan-To changed the title [BUG] git is unable to add 'git-core' to the PATH when run using npm scripts [BUG] git is unable to add 'git-core' to the PATH when it is run using npm scripts Jul 3, 2020
@darcyclarke darcyclarke added Release 6.x work is associated with a specific npm 6 release Bug thing that needs fixing labels Oct 30, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 6.x work is associated with a specific npm 6 release
Projects
None yet
2 participants