Reputation: 6299
I have a private Bitbucket repository. Git clone succeeds:
git clone [email protected]: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 [email protected]
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://[email protected]/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://[email protected]/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?
Upvotes: 3
Views: 2972
Reputation: 444
My solution on Windows:
C:/Users/<username>/.ssh/config
with entryHost bitbucket.org
IdentityFile ~/.ssh/bitbucket_key
IdentitiesOnly yes
C:/Users/<username>/.ssh/bitbucket_key
C:/Users/<username>/.gitconfig
like this[credential]
helper = manager
interactive = false
modalPrompt = false
This solution also works in VS Code console, but you have to cancel the credential popups when they appear (I didn't find the way to disable them yet).
Upvotes: 0
Reputation: 50422
Although the question is about Bitbucket, I think an issue I got with Github but with the exact same trace can help you solve your problem.
For me, only changing the url didnt make it work. Here are the steps I had to take to fix this :
git+ssh://[email protected]:owner/repo.git#master
~/.ssh/config
create the file if it doesnt exist) to force the use of the DeployKey instead of the default ssh key. (be sure to reference the private key part of the deploy key in the ssh config file)After that the npm install simply worked. All the other options and solutions resulted of the npm install breaking
Upvotes: 1
Reputation: 180
;TLDR
(Windows OS issue)
Manually delete %appdata%\Roaming\npm-cache
I had similar errors. One thing I tried was npm cache clean, which took used a lot of CPU and never "finished". So I went to %appdata%\Roaming\npm-cache
and tried to delete, I couldn't.
I had to right click the folder >> Properties >> Security >> Advanced >> Permissions tab I clicked my username, then I checked "Replace all child object permission entries...", then clicked Apply.
For some reason my git remotes in the cache didn't have permissions under the security tab. After this my npm install
worked.
Upvotes: 0
Reputation: 6299
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...
Upvotes: 0