Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bun install with Gitlab repository in dependencies not working #4068

Closed
DrWarpMan opened this issue Aug 8, 2023 · 8 comments · Fixed by #11917
Closed

bun install with Gitlab repository in dependencies not working #4068

DrWarpMan opened this issue Aug 8, 2023 · 8 comments · Fixed by #11917
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client

Comments

@DrWarpMan
Copy link

DrWarpMan commented Aug 8, 2023

What version of Bun is running?

0.7.3

What platform is your computer?

Linux 6.4.7-arch1-1 x86_64

What steps can reproduce the bug?

  1. bun init
  2. Add Gitlab dependency like this, in package.json:
"dependencies": {
    "package": "git+ssh://[email protected]:foobar.git"
}
  1. bun install

What is the expected behavior?

Gitlab dependency should be installed without errors.

What do you see instead?

bun install v0.7.3 (a9b3d583)
  🔍 Resolving [1/1] 
error: InstallFailed cloning repository for "<package-name>"
error: "git clone" for "<package-name>" failed
error: "git clone" for "<package-name>" failed

Additional information

  1. HTTPS protocol works, SSH doesn't.
    git+https://gitlab.example.com/foobar.git
    git+ssh://[email protected]:foobar.git

  2. npm install works just fine.

  3. I would assume this might be an issue on Github as well, haven't tested though.

@DrWarpMan DrWarpMan added the bug Something isn't working label Aug 8, 2023
@robobun robobun added the bun install Something that relates to the npm-compatible client label Aug 8, 2023
@mozkomor05
Copy link

mozkomor05 commented Aug 20, 2023

Git supports two URL syntaxes for SSH cloning:

  1. git clone [email protected]:foobar.git
  2. git clone ssh://[email protected]/foobar.git (notice the use of a slash instead of a colon)

So, in a way, it makes perfect sense for Bun not to support git+ssh://[email protected]:foobar.git. However, NPM does support it, and for Bun to be a drop-in replacement, it should also support it.

In my opinion, it makes sense to incorporate a trySSH logic that would check different SSH url formats, similar to the existing tryHTTPS, similar to how it's done here:

bun/src/install/install.zig

Lines 666 to 684 in 3a9a6c6

if (Repository.tryHTTPS(url)) |https| break :brk Repository.download(
manager.allocator,
manager.env,
manager.log,
manager.getCacheDirectory().dir,
this.id,
name,
https,
) catch null;
break :brk null;
} orelse Repository.download(
manager.allocator,
manager.env,
manager.log,
manager.getCacheDirectory().dir,
this.id,
name,
url,
) catch |err| {

@DrWarpMan
Copy link
Author

https://docs.npmjs.com/cli/v9/commands/npm-install#description

npm install git+ssh://[email protected]:npm/cli.git#v1.0.27
npm install git+ssh://[email protected]:npm/cli#pull/273
npm install git+ssh://[email protected]:npm/cli#semver:^5.0
npm install git+https://[email protected]/npm/cli.git
npm install git://github.com/npm/cli.git#v1.0.27

Here are the formats that NPM supports.

@Eckhardt-D
Copy link
Contributor

Is there any feedback on this? v1.0.5 still cannot clone private [email protected]:org/repo.git urls. It attempts the clone but fails, assuming that it's either an issue with missing ssh key in the connect or something else. The error is quite vague:

error: FileNotFound cloning repository for db-migrations

Is it perhaps trying to look at Github instead of Gitlab?

@h2oearth
Copy link

I tested the latest version (1.0.6) , and the public repos seem to work, but I can not access my private repos. :-/

@Eckhardt-D
Copy link
Contributor

Eckhardt-D commented Oct 13, 2023

I tested the latest version (1.0.6) , and the public repos seem to work, but I can not access my private repos. :-/

That seems like Bun install is not using the ssh key. id_rsa gets automatically used in other pm’s. @Jarred-Sumner

it should also handle for example (~/.ssh/config):

Host gitlab.com
     IdentityFile ~/.ssh/gitlab_key
     IdentitiesOnly yes

@MikkelSVDK
Copy link

I have the same issue, bun does not use my public key to download from a git repo.

Resulting in this mess

bun install v1.0.11 (f7f6233e)
[3.32ms] migrated lockfile from package-lock.json
Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com': Username for 'https://git.mygitrepo.com':   🚚 brace-expansion

error: no commit matching "semver:~1.0.0" found for "@my-app/project" (but repository exists)

My package.json looks like this

{
  ...
  "dependencies": {
    "@my-app/project": "git+ssh://[email protected]/my-app/project.git#semver:~1.0.0",
    ...
  }
}

Another note is, the terminal stops displaying any characters you type, cause it somewhere disables the output, but never enables it again after i fails.

@Eckhardt-D
Copy link
Contributor

Obligatory 6 month follow-up. Installing private GitLab repos with bun + shh (using any ssh URL) does not work. The installer prompts for the ssh password, when it should be using the host's SSH key. 🔑

@h2oearth
Copy link

Any news @Bun team?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client
Projects
None yet
6 participants