I recently upgraded to yarn v0.27.5 (from 0.24.5) and installing from private github repositories via git+ssh doesn't work anymore. It's working fine in v0.24.5 and npm.
node: v8.0.0
npm: v5.0.0
yarn: v0.27.5
os: macOS 10.12.5
@formatlos We can really use more details for reproduction steps and the error you are getting.
when trying to add a private github repository
yarn add git+ssh://[email protected]:XXXX/private-repository.git
I get a permission denied error:
yarn add v0.27.5
[1/4] Resolving packages...
error Command failed.
Exit code: 1
Command: git
Arguments: pull
Directory: /Users/Martin/Library/Caches/Yarn/v1/.tmp/e841342d6c58f4c04674d97e4bbf827a
Output:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Installing the same repository with yarn v0.24.5, npm or git directly works as expected..
Can you try the latest 0.28.1? I think your git was relying on certain environment variables for authentication which were stripped due to a bug in 0.27.
The same error occurs with 0.28.1 (with clean cache).
Can you confirm that you can git clone that repository from your shell?
yes, as I said git clone and npm install works fine
@formatlos are you running SSH agent? Can you provide more details please?
I got it working now using SSH agent. I was using just keychain before, but adding AddKeysToAgent to my ssh config fixed it.
Host *
UseKeychain yes
AddKeysToAgent yes
Glad you got it sorted out. Do you think this was a bug on Yarn's side or can we close this?
Good question. As it is working with git clone and npm install I'd still think that it's an issue on Yarn's side, but I don't mind closing it, if using SSH agent fixes the issue.
@formatlos if you'd be comfortable sharing some of your configuration or are willing to debug and try fixing this issue, it may help other people. I suspect some ENV variable not getting passed properly or getting mangled but can't really prove that without access to your system. What do you think, can you help us?
depends a little on which kind of configuration I'd have to share but in general I can help fixing the issue, just tell me what I have to test or send.
@formatlos actually, one thing that came to my mind: were you entering any password during npm install or git clone or it was completely non-interactive once you issued the command?
haven't entered the passphrase for quite some time (at least a few months) as I added it to the keychain when I created the ssh key.
I'm pretty sure this is related to #3633 but I can't really make the connection. May be if you can share the values of those environment variables or any local git overrides that may affect these settings we may be able to figure it out?
all of the env vars are empty and I also don't have any other local git overrides. I'm on git version 2.13.0
Okay then I'm gonna close this as a fluke for now and just hope if other people have any similar issues, they report it here.
Thanks a lot for your help!
I have the same issue on yarn 0.27.5, macOS Sierra. git clone and npm i work fine. updating the ssh config did not solve it for me. Adding ssh-add -K to my .zshrc did the trick. I would suggest this is a yarn bug though since it works fine with npm i and with git clone, without any "extra steps"
Same problem here, 0.26.1 works OK, 0.27.5 and 0.28.1 failed with the same error:
yarn install v0.28.1
[1/4] 馃攳 Resolving packages...
[2/4] 馃殮 Fetching packages...
error Command failed.
Exit code: 1
Command: git
Arguments: pull
Directory: /Users/XXXXX/Library/Caches/Yarn/v1/.tmp/77979a5e9cb1d38c3384a64a11d2c1f6
Output:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
same here. Adding AddKeysToAgent didn't do the trick.
Are you using a proxy for Git or SSH connections?
AddKeysToAgent worked, just had to force an SSH connection to the remote with a push or pull first.
@Agrosis's workaround worked here also.
Hey, we were having that same issue on some or our machines and we figured out we had to upgrade yarn to the latest version, which at the time of writing is 1.3.2. Now it works fine.
Most helpful comment
AddKeysToAgentworked, just had to force an SSH connection to the remote with a push or pull first.