I have a HOME
environment variable set in Windows to point to a folder, C:\tom\
.
When I run git from the command line, and it invokes ssh, it ends up looking for the ~/.ssh
folder, or $HOME/.ssh
, and finds C:\tom\.ssh
. This side of things works fine.
When npm runs git, on the other hand, as it might when trying to get a dependency that refers to a private github repo, ssh seems to end up trying C:\Users\tom\.ssh
, aka %USERPROFILE%\.ssh
. But that folder doesn't exist on my PC, so ssh fails, because it can't find the known_hosts
entry for github, and ultimately git fails:
npm ERR! Command failed: git -c core.longpaths=true fetch -a origin
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm config list
produces the following:
; cli configs
user-agent = "npm/3.10.8 node/v6.9.1 win32 x64"
; builtin config undefined
prefix = "C:\\Users\\tom\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files (x86)\nodejs\node.exe
; cwd = C:\
; HOME = C:\Users\tom
; "npm config ls -l" to show all defaults.
So that makes sense, and presumably npm's HOME setting is coming through in the environment when it runs git. So I tried npm config set HOME C:\tom
, hoping this would fix things... but it made no difference.
How do I sort this out? I want ssh always to find C:\tom\.ssh
. I don't ever want it to find C:\Users\tom\.ssh
. How can I make that happen? I don't mind if I have to do this by tweaking some setting, if there's some option that stops npm modifying the environment, or something else.