question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] It's impossible to install packages from private Github repos (git+ssh protocol)

See original GitHub issue

My dependencies look like:

"@someorg/somepackage": "git+ssh://git@github.com:someorg/somepackage.git"

I follow this article to set up my MacOS: https://docs.github.com/en/enterprise/2.15/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

In Yarn 1 it works well.

But in Yarn 2 I see so error:

aleksandr@iMac someproject % yarn
➤ YN0000: ┌ Resolution step
➤ YN0001: │ Error: @someorg/somepackage@git+ssh://git@github.com:someorg/somepackage.git: Listing the refs for git+ssh://git@github.com:someorg/somepackage.git failed
    at ChildProcess.h.on.n (/Users/aleksandr/WebProjects/someproject/.yarn/releases/yarn-berry.js:2:325427)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:198:13)
    at Pipe._handle.close (net.js:607:12)
➤ YN0000: └ Completed in 5.89s
➤ YN0000: Failed with errors in 5.9s

I.e. Yarn 1 requests my keychain and uses SSH private key but Yarn 2 doesn’t do it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
LvChengbincommented, Aug 20, 2020

@MrEfrem The “git+ssh://” format can still be used in Yarn 2, but others reasons caused this issue.

Thank you so much @arcanis. It’s not a bug of Yarn 2, but I think Yarn 2 may need to help to resolve this problem. While using git+ssh://git@github.com:someorg/somepackage.git Yarn 2 will run git ls-remote --refs ssh://git@github.com:someorg/somepackage.git to list remote refs, but git cannot parse the host correctly, it seems to regard github.com:someorg as the host like hostname + port, and will output the error message:

ssh: Could not resolve hostname github.com:someorg: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Adding a slash after the colon(😃 can resolve this problem:

`git ls-remote --refs ssh://git@github.com:/someorg/somepackage.git`

So, we need to use git+ssh://git@github.com:/someorg/somepackage.git instead the old version.

But I think Yarn 2 need to help users to resolve this problem because:

  • Both github and gitlab display the incorrect format on there webpages, it’s convenient to copy the URL directly by clicking the copy button.
  • Both Yarn 1 and NPM support the format without slash after colon, so, I cannot install some other packages which are using this format in there package.json files.
0reactions
MichaelBaySAPcommented, Dec 9, 2021

It turns out, for my yarn it works best, if I run yarn install with the following package.json configuration:

"name": "https://github.com/org/repository"

However, I found this out after running git ls-remote https://github.com/org/repository yielded the refs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't install package from private GitHub repository with Yarn ...
Running yarn add git+ssh://git@github.com:adamwathan/my-package ... Same issue as well, though it's a private Bitbucket repo and yarn 1.3.2.
Read more >
Unable to install package from private repository #1393 - GitHub
I am attempting to install from a private repository. The output indicates the package and dependencies were installed but when pipenv is ...
Read more >
Unable to install from private repo with git+ssh #2653 - GitHub
Issue description I am unable to install package from a private gitlab repo via git+ssh. It works fine with pip but not with...
Read more >
It is possible to add a dependency of a private git repo? #835
I've just stated to use poetry, I quite like some of the features, but i'm now stuck since installing a private repo doesn't...
Read more >
git+ssh package install does not seem to work #513 - GitHub
No, sorry. It wasn't actually from my personal github though. It's "git+ssh://git@github.com/<org>/<package>.git". The repo is private and I ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found