This repository has been archived by the owner. It is now read-only.

npm doesn't pass GIT_EXEC_PATH to git on install #13353

Closed
mhart opened this Issue Jul 12, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@mhart
Contributor

mhart commented Jul 12, 2016

I'm opening this issue because:

  • npm is producing an incorrect install.

What's going wrong?

If git is installed in a non-default location, and uses GIT_EXEC_PATH to specify this location, then git will work normally in all cases (even in npm scripts), except when invoked during installs:

npm ERR! ... fatal: Unable to find remote helper for 'https'

... because git can't find git-remote-https which exists in the GIT_EXEC_PATH

npm has a hardcoded whitelist of env variables that it passes down to git which causes this, and it does not include GIT_EXEC_PATH.

How can the CLI team reproduce the problem?

Install git (on a system that doesn't have it) in a custom location and export GIT_EXEC_PATH to this location. Confirm that git cloning of https repos works fine on the command line. Confirm that it works fine when run from an npm script even. Then try:

$ npm install https://github.com/uberVU/Sinon.JS
npm ERR! git clone --template=/tmp/home/.npm/_git-remotes/_templates --mirror https://github.com/uberVU/Sinon.JS.git /tmp/home/.npm/_git-remotes/https-github-com-uberVU-Sinon-JS-git-5ff91d4d: Cloning into bare repository '/tmp/home/.npm/_git-remotes/https-github-com-uberVU-Sinon-JS-git-5ff91d4d'...
npm ERR! git clone --template=/tmp/home/.npm/_git-remotes/_templates --mirror https://github.com/uberVU/Sinon.JS.git /tmp/home/.npm/_git-remotes/https-github-com-uberVU-Sinon-JS-git-5ff91d4d: fatal: Unable to find remote helper for 'https'

supporting information:

Happens on npm v3.10.3 and v2.14.12
Node.js v6.3.0 and v4.3.2
Linux

Suggested solutions

  • add GIT_EXEC_PATH to the whitelist, OR preferably:
  • Actually allow all GIT_* variables – because this issue has come up before and will probably come up again due to the many GIT_* variables that exist: http://man7.org/linux/man-pages/man1/git.1.html – and users should have a reasonable expectation that npm will respect their git configuration. If there is actually a problem with certain variables, then they should be blacklisted – otherwise I fear this will be a constant chase.

Impact

This is currently causing issues for LambCI which has git installed in a custom location (due to filesystem/root restrictions): lambci/lambci#28

@lielran

This comment has been minimized.

lielran commented Jul 12, 2016

+1

@mhart mhart changed the title from npm doesn't pass necessary env variables (like PATH and LD_LIBRARY_PATH) on install to npm doesn't pass necessary env variables to git (like PATH and LD_LIBRARY_PATH) on install Jul 12, 2016

@mhart mhart changed the title from npm doesn't pass necessary env variables to git (like PATH and LD_LIBRARY_PATH) on install to npm doesn't pass necessary env variables to git on install Jul 12, 2016

@mhart

This comment has been minimized.

Contributor

mhart commented Jul 12, 2016

Ok, looking into this further, it may just be the GIT_EXEC_PATH variable that needs to be passed in.

If so, that's probably a lot easier to stomach – because it's in line with the other GIT_ variables that are already whitelisted

@mhart

This comment has been minimized.

Contributor

mhart commented Jul 12, 2016

OK, confirmed, passing GIT_EXEC_PATH let's it install.

I'll create pull requests for two alternatives:

  1. Just add GIT_EXEC_PATH to the whitelist
  2. Modify the env checker to allow all env variables that start with GIT_ to be passed to git. This makes the most sense to me and will hopefully prevent more issues like this from popping up in the future – there are quite a few more GIT_ variables that npm doesn't pass through, and I really think it should if it's trying to respect git's normal execution.

EDIT: looking more closely at the code, it seems that the current check is allowing all env variables except GIT* ones that don't appear in the whitelist. This seems... counter-intuitive. There must be specific variables that caused this code to be there in the first place – most GIT* variables should be passed through so that git behaves in the same way the user has set it up for

@mhart mhart changed the title from npm doesn't pass necessary env variables to git on install to npm doesn't pass all GIT_* variables to git on install Jul 12, 2016

@mhart mhart changed the title from npm doesn't pass all GIT_* variables to git on install to npm doesn't pass all GIT_* env vars to git on install Jul 12, 2016

mhart added a commit to lambci/npm that referenced this issue Jul 12, 2016

mhart added a commit to lambci/npm that referenced this issue Jul 12, 2016

mhart added a commit to lambci/lambci that referenced this issue Jul 12, 2016

Bundle in npm v2.15.9 with GIT_EXEC_PATH fix
Need our own custom branch until
npm/npm#13353 is fixed.

Fixes #28

@mhart mhart changed the title from npm doesn't pass all GIT_* env vars to git on install to npm doesn't pass GIT_EXEC_PATH to git on install Jul 12, 2016

@mhart

This comment has been minimized.

Contributor

mhart commented Jul 12, 2016

Created #13358 to address the most immediate problem.

iarna added a commit that referenced this issue Aug 11, 2016

iarna added a commit that referenced this issue Aug 11, 2016

@iarna iarna closed this in e7fa6c6 Aug 12, 2016

@sebhewelt

This comment has been minimized.

sebhewelt commented Nov 9, 2016

I tried to install a package to atom and i got a similar error.
I opened the add-git-remote.js file with variables and 'GIT_EXEC_PATH' was there, so I don't know what may be the other reason. I use windows 10, paths to git,bash and atom are working correctly, apm is recognized.

Anyway i still get this:

npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:213:12)
npm WARN addRemoteGit     at emitTwo (events.js:87:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:172:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:827:16)
npm WARN addRemoteGit     at Socket.<anonymous> (internal/child_process.js:319:11)
npm WARN addRemoteGit     at emitOne (events.js:77:13)
npm WARN addRemoteGit     at Socket.emit (events.js:169:7)
npm WARN addRemoteGit     at Pipe._onclose (net.js:477:12)
npm WARN addRemoteGit  git+https://github.com/millermedeiros/rocambole.git#1bd5044df1d6c888a1bd1b511158fb34b011e9aa resetting remote C:\Users\Sebastian\.atom\.apm\_git-remotes\git-https-github-com-millermedeiros-rocambole-git-1bd5044df1d6c888a1bd1b511158fb34b011e9aa-af4fdf85 because of error: { [Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit ]
npm WARN addRemoteGit   killed: false,
npm WARN addRemoteGit   code: 1,
npm WARN addRemoteGit   signal: null,
npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm ERR! git clone --template=C:\Users\Sebastian\.atom\.apm\_git-remotes\_templates --mirror https://github.com/millermedeiros/rocambole.git C:\Users\Sebastian\.atom\.apm\_git-remotes\git-https-github-com-millermedeiros-rocambole-git-1bd5044df1d6c888a1bd1b511158fb34b011e9aa-af4fdf85: Cloning into bare repository 'C:\Users\Sebastian\.atom\.apm\_git-remotes\git-https-github-com-millermedeiros-rocambole-git-1bd5044df1d6c888a1bd1b511158fb34b011e9aa-af4fdf85'...
npm ERR! git clone --template=C:\Users\Sebastian\.atom\.apm\_git-remotes\_templates --mirror https://github.com/millermedeiros/rocambole.git C:\Users\Sebastian\.atom\.apm\_git-remotes\git-https-github-com-millermedeiros-rocambole-git-1bd5044df1d6c888a1bd1b511158fb34b011e9aa-af4fdf85: fatal: Unable to find remote helper for 'https'
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Users\\Sebastian\\AppData\\Local\\atom\\app-1.11.2\\resources\\app\\apm\\bin\\node.exe" "C:\\Users\\Sebastian\\AppData\\Local\\atom\\app-1.11.2\\resources\\app\\apm\\node_modules\\npm\\bin\\npm-cli.js" "--globalconfig" "C:\\Users\\Sebastian\\.atom\\.apm\\.apmrc" "--userconfig" "C:\\Users\\Sebastian\\.atom\\.apmrc" "install" "C:\\Users\\SEBAST~1\\AppData\\Local\\Temp\\d-116109-5848-1bpzttt\\package.tgz" "--runtime=electron" "--target=0.37.8" "--arch=ia32" "--global-style"
npm ERR! node v4.4.5
npm ERR! npm  v3.10.5
npm ERR! code 128

npm ERR! Command failed: git -c core.longpaths=true clone --template=C:\Users\Sebastian\.atom\.apm\_git-remotes\_templates --mirror https://github.com/millermedeiros/rocambole.git C:\Users\Sebastian\.atom\.apm\_git-remotes\git-https-github-com-millermedeiros-rocambole-git-1bd5044df1d6c888a1bd1b511158fb34b011e9aa-af4fdf85
npm ERR! Cloning into bare repository 'C:\Users\Sebastian\.atom\.apm\_git-remotes\git-https-github-com-millermedeiros-rocambole-git-1bd5044df1d6c888a1bd1b511158fb34b011e9aa-af4fdf85'...
npm ERR! fatal: Unable to find remote helper for 'https'
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\SEBAST~1\AppData\Local\Temp\apm-install-dir-116109-5848-q1ndn2\npm-debug.log

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.