Search code examples
gitsshnpmssh-keysnpm-install

Private repo, git clone succeeds, npm install fails


I have a private Bitbucket repository. Git clone succeeds:

git clone git@bitbucket.org:user/repo.git

It finds my SSH key settings (~/.ssh/config), asks for passphrase (actally it does not recognize Pageant, I don't think it should though) and everything runs smoothly. The common SSH test is also ok:

> ssh -T git@bitbucket.org

This is redirected to putty, it finds the SSH config, the key in Pageant and logs in without problem. If I use the internal ssh.exe of Git then it finds the key but not Pageant so I have to manually type the passphrase then everything is fine.

However, npm install fails (some details omitted):

> npm i git+ssh://git@bitbucket.org/user/repo.git
npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
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:475:12)
npm WARN addRemoteGit  git+ssh://git@bitbucket.org/user/repo.git resetting remote C:\... 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! ... Cloning into bare repository 'C:\...'...
npm ERR! ... Permission denied (publickey).
npm ERR! ... Could not read from remote repository.
npm ERR! ... Please make sure you have the correct access rights
npm ERR! ... and the repository exists.
npm ERR! Windows_NT 6.3.X
npm ERR! node v4.4.0
npm ERR! npm  v3.8.1

If I clone the repo then npm install in the cloned directory then everything is fine -- so that shouldn't be the problem either. (Too long paths neither are the problem I guess.) So, Y U no work?


Solution

  • It seems to be an issue: https://github.com/npm/npm/issues/11567 + the further linked issues.

    I don't know whether they gonna solve this because private NPM hosting is their business...