Do you want to request a _feature_ or report a _bug_?
bug
What is the current behavior?
yarn add
returns "Permission denied" error
โ yarn add [email protected]:szemek/cheatsheets.git
yarn add v0.15.1
[1/4] ๐ Resolving packages...
error Command failed.
Exit code: 128
Command: git
Arguments: clone github.com:szemek/cheatsheets.git /Users/szemek/.yarn-cache/.tmp/087b27ef145b8d7861743348d6045535
Directory: /Users/szemek/project
Output:
Cloning into '/Users/szemek/.yarn-cache/.tmp/087b27ef145b8d7861743348d6045535'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
at SpawnError (/Users/szemek/.yarn/lib/errors.js:18:1)
at ChildProcess.proc.on.code (/Users/szemek/.yarn/lib/util/child.js:107:15)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:850:16)
at Socket.<anonymous> (internal/child_process.js:323:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:485:12)
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.
If the current behavior is a bug, please provide the steps to reproduce.
yarn add [email protected]:<user>/<repository>.git
What is the expected behavior?
As you can notice in: Arguments: clone github.com:szemek/cheatsheets.git /Users/szemek/.yarn-cache/.tmp/087b27ef145b8d7861743348d6045535
git@
shouldn't be stripped from git remote url.
_Note_: it doesn't matter that mentioned repository doesn't contain package.json
. For my private repository with https protocol it worked just fine.
Please mention your node.js, yarn and operating system version.
node.js v6.0.0
yarn 0.15.1
OS X 10.11.6
The split and removal of the git
prefix occurs here: https://github.com/yarnpkg/yarn/blob/master/src/package-request.js#L161
I traced it to: https://github.com/yarnpkg/yarn/blob/master/src/resolvers/exotics/git-resolver.js#L33
Issue confirmed for me as well, I'm unable to add a git remote directly as specified above.
This doesn't work with npm either: npm install [email protected]:szemek/cheatsheets.git
, are you sure this should work? Are you missing the protocol?
Absolutely, assuming you add the protocol as required.
In fact, this line from my package.json
is preventing me from actually trying yarn right now:
"postcss-brunch": "git+ssh://[email protected]:brunch/postcss-brunch.git#b361e97",
You can try for yourself with
npm install git+ssh://[email protected]:brunch/postcss-brunch.git#b361e97
Ah, I've got a PR to fix that one here: https://github.com/yarnpkg/yarn/pull/934
That specifically is an issue with the auth segment of the URL (git@
).
Ohh, it doesn't work with the SSH syntax either, though.
I've got a fix prepared for SSH URLs. Need to add tests and check a few other places too, but it's late here so I'll continue tomorrow https://github.com/danharper/yarn/commit/2eaf66daa470e2e2afde72576d5af2781386987c (explanation is in the commit message)
@danharper cool, since you are moving exotic resolvers higher priority, see if you can remove this code, as moving the priority might resolve #59 and make this code unnecessary?
@troydemonbreun I've got a PR open for that here: #934. Basically replaces that block with a protocol check instead.
This doesn't work with npm either: npm install [email protected]:szemek/cheatsheets.git, are you sure this should work? Are you missing the protocol?
@danharper I checked npm (v3.8.6) installation. It returns:
npm ERR! Unsupported URL Type: github.com:szemek/cheatsheets.git
For me it's better information than misleading error with lack of access.
Thanks for working on this ๐
Thanks for working on this ๐
Hi,
Is this issue resolved in the latest version?
I have just tried on latest nightly (0.18.0-20161114.1729) and the issue remains.
Is there a workaround? Is this bug difficult to resolve? It seems to simple to avoid mangling the git URL we inform in the command line...
This works: npm i --save git+ssh://gitlab.com/user/repo.git#1.0.0
This doesn't work: yarn add git+ssh://gitlab.com/user/repo.git#1.0.0
With or without the #1.0.0
part.
yarn add v0.18.1
info No lockfile found.
[1/4] ๐ Resolving packages...
error Command failed.
Exit code: 128
Command: git
Arguments: clone ssh://gitlab.com/user/repo.git /Users/aleclarson/Library/Caches/Yarn/.tmp/7a49a436907360ab3ea50e6a2a82f300
Directory: /Users/aleclarson/lib/modules/foo
Output:
Cloning into '/Users/aleclarson/Library/Caches/Yarn/.tmp/7a49a436907360ab3ea50e6a2a82f300'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Here's the workaround:
yarn add git+ssh://[email protected]/user/repo.git#1.0.0
Notice the git@
before gitlab.com
The original issue doesn't seems like a bug, in that Yarn is (somewhat rightfully) trying to install the git
package from the location github.com:szemek/cheatsheets.git
. We could special-case this in order to solve the ambiguity for [email protected]
, but it seems like the best fix would be to use git+ssh urls.
I'm going to close this issue for triage, but discussion is still open.
Why close the issue rather than fix it? Community wants it working and is contributing for its solution.
As far as I understood, the fix relies on simply letting the URL informed in the command line as it is, instead of changing it to some kind of guess.
@jbruni There's an ambiguity in the command line grammar. If you write [email protected]:a/b
, it can be interpreted as either the foo
package at bar.com:a/b
, or the package located at [email protected]:a/b
. Considering you can still install the package by resolving the ambiguity (by using a git+ssh://
protocol) and that reversing this behavior would remove this ability to solve the ambiguity, I'm not sure this is something worth special-casing. How do you suggest we fix it?
Maybe we can improve the ambiguity resolution strategy - since in this case it is failing.
Maybe we can keep it as it is, but if there is a fail to install that package, then it could "make another guess", ie, assume the other possibility of interpretation is correct, and try it.
Tried all variations mentioned here, none works. So how to add package by branch or commit? :/
only http works for me now:
yarn add https://github.com/yarnpkg/yarn.git#20e5779ec324b3103ef9cca14ce9f96d29fd93c6
I also got this error, and checked the git config and repo auth setup, but got nothing. Then removed nvm, node(installed from brew), yarn(installed from brew), then just install node from official web, and yarn from npm. Did not install nvm. Then, it's allright!!!
I cannot able to explain why it is. Maybe nvm or not. Hope can help anyone.
url pattern of installed pkg in package.json:
"pkgFoo": "git+ssh://git@host:opensource/foo.git#xxx"
In my case it was asking for my password, then for some reason it always failing with this same error, after the command ssh-add -K
it stops to fail
seeing this in yarn 0.27.5
and @aleclarson's solution did not work although npm install
works. Is this an issue again?
@daviskoh can you try with the latest nightlies?
Also what is your git version? Are you using a proxy for git etc.?
For me it worked with 0.25.2 with my ssh keys (for bitbucket) in pageant, but it does not work with 0.27.0
git --version
git version 2.7.0.windows.1
from log: uri for repository: clone [email protected]:.....
!but in my package.json and yarn.lock the URI is: git+ssh://[email protected]:....
@BYK it worked after adding the following to my ~/.ssh/config:
Host *
AddKeysToAgent yes
and forcing a pull / push on the private repo 1st I'm guessing to "show" I have permissions on it. Cant remember which user and which git issue suggested to do this as there are a lot of similar issues.
My git version: 2.11.0
@natecox thanks your anwser! git url must add prefix git+ssh://[url]
good resolve!
The funny part is that I'm trying to do the same with Yarn & Phabricator (both FB technology) and it also doesn't seem to work (only over https). Connection simply timesout.
hey I am facing the same issue but I also have a passphrase on my ssh which is why i am getting Permission denied
Was hitting this issue as well and prefixing with git+ssh://
helped me as well. Here's the final line that worked for me: yarn add git+ssh://[email protected]:keego/ros3djs.git#ES6_ONLY
Note: this is a public repo so I didn't have any permission issues
I am hitting the same Permission denied (publickey)
during yarn install
with yarn 1.7.0 on PowerShell/Windows when trying to access a private git repo using a url like this:
"dependencies": {
"git+ssh://[email protected]/MyUser/MyRepo.git#abcdef1234..."
}
This is with ssh-agent running. I can access the private repo fine from git on the command line. npm install
also works fine.
It looks like my problem came from using the new OpenSSH for Windows 10. I uninstalled this via "Manage Optional Features" (which required a reboot), and then installed posh-git. After running start-sshagent
I was able to run yarn install
from PowerShell.
Although I use git on WSL everywhere else, this requires git for windows.
THIS DOES NOT WORK IF YOU WANT TO SETUP WITH PASSPHRASE.
cd ~/.ssh
or on Windows go to C:\Users\<username>\.ssh
and open GitBash/Cygwin there.ssh-keygen
id_rsa.pub
id_rsa.pub
) and copy the key inside. (ctrl+A and ctrl+C)[email protected]: Permission denied (publickey)
Does this work if you have a passphrase set?
@mikebridge, no it does not work with passphrase. :(
yarn add git://github.com/<username>/<package name>.git
getting the same error on
node version : 8.0.0
yarn version : v1.5.1
when running yarn
on docker image 'node:8.10.0'
my package dependencies look like this
"dependencies": {
"prop-types": "^15.6.2",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"rx-connect": "git://github.com/herman-rogers/rx-connect.git#lib",
"rxjs": "^6.3.3",
"styled-components": "^3.4.10"
}
Build fails when yarn
is executed with the following errors
+ yarn
yarn install v1.5.1
[1/4] Resolving packages...
[2/4] Fetching packages...
warning Pattern ["core-js@latest"] is trying to unpack in the same destination "~/.cache/yarn/v1/npm-core-js-2.5.7-f972608ff0cead68b841a16a932d0b183791814e" as pattern ["core-js@^2.5.7","core-js@^2.2.0","core-js@^2.5.3","core-js@^2.4.0","core-js@^2.5.0","core-js@^2.2.0","core-js@^2.5.0"]. This could result in non-deterministic behavior, skipping.
error An unexpected error occurred: "Command failed.
Exit code: 128
Command: git
Arguments: clone git://github.com/herman-rogers/rx-connect.git ~/.cache/yarn/v1/.tmp/422be2b3c5a69d0ac7b460ec5dc102ae
Directory: /home/ec2-user/workspace/vitaTeam_uvita-webapp_PR-86-MYDWWK7BGXIUJU5B3TBMMRJIVK6ZBXDR5S2PET2RO5MXSNNAHTRA
Output:
Cloning into '~/.cache/yarn/v1/.tmp/422be2b3c5a69d0ac7b460ec5dc102ae'...
fatal: unable to look up current user in the passwd file: no such user".
info If you think this is a bug, please open a bug report with the information provided in "/home/ec2-user/workspace/vitaTeam_uvita-webapp_PR-86-MYDWWK7BGXIUJU5B3TBMMRJIVK6ZBXDR5S2PET2RO5MXSNNAHTRA/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
script returned exit code 1
Most helpful comment
In my case it was asking for my password, then for some reason it always failing with this same error, after the command
ssh-add -K
it stops to fail