oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
72.41k stars 2.59k forks source link

Implement semver protocol for git dependencies in `bun install` #5870

Open doloboyz opened 10 months ago

doloboyz commented 10 months ago

What version of Bun is running?

1.0.2

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

  1. Paste the following into the terminal mkdir unw-bug && cd unw-bug && bun init

  2. Go to package.json and add the following as a dependency:

    "dependencies": {
        "uWebSockets.js": "github:uNetworking/uWebSockets.js#semver^20.31.0"
    },

    Alternatively, run bun add uNetworking/uWebSockets.js

  3. Run bun install

What is the expected behavior?

Should result in successful install.

What do you see instead?

On bun add uNetworking/uWebSockets.js, the following is the output to the terminal:

🔍 Resolving [1/2] error: InstallFailed cloning repository for uWebSockets. 🚚 uNetworking/uWebSockets.js [3/3] error: InstallFailed extracting tarball for uNetworking/uWebSockets.

error: "git clone" for "uWebSockets.js" failed

error: "git clone" for "uWebSockets.js" failed

error: "package.json" for "uNetworking/uWebSockets.js" failed to open: FileNotFound

If running bun install with the pasted dependency provided above, the following is the output:

bun install v1.0.2 (37edd5a6) 🔍 Resolving [1/1] error: InstallFailed cloning repository for uWebSockets.

error: "git clone" for "uWebSockets.js" failed

error: "git clone" for "uWebSockets.js" failed

Additional information

No response

ThomasMoritz commented 10 months ago

@doloboyz The strange thing is if you do bun add uNetworking/uWebSockets.js#v20.31.0 it works!? (on Darwin 22.6.0 arm64 arm with Bun 1.0.2)

doloboyz commented 10 months ago

@doloboyz The strange thing is if you do bun add uNetworking/uWebSockets.js#v20.31.0 it works!? (on Darwin 22.6.0 arm64 arm with Bun 1.0.2)

Seems to still fail for me on m1 macbook pro on Ventura 13.5. Going to upgrade to 13.6 tonight, but I highly doubt thats going to fix the issue.

dpnova commented 10 months ago

Have spotted the same issue running: bun add @graphql-mesh/cli graphql

FYI @ardatan

farabi-brighte commented 9 months ago

Have spotted the same issue running: bun add @graphql-mesh/cli graphql

Same issue here. Trying to build graphql mesh with Bun.

riki137 commented 9 months ago

We're having the same issue with : "git@gitlab.com/..." dependency which stops us from migrating to bun.

bun add v1.0.4 (745b6b94)
  🚚 chooze [2/3] error: InstallFailed extracting tarball for choo

error: ZlibError decompressing "chooze"
peniqliotuv commented 9 months ago

Same thing with @types/chai

❯ bun install
bun install v1.0.7 (b0393fba)
  🔍 read-package-json-fast [765/1763]

error: "git clone" for "@types/chai" failed

error: "git clone" for "@types/chai" failed
subodhpareek18 commented 8 months ago

I have a private github repository as a dependency in the format like this

{
  "dependencies": {
     "REPO": "https+git://TOKEN@github.com/ORG/REPO.git"
  }
}

It works when doing bun add but not when doing bun install

subodhpareek18 commented 8 months ago

Is there a way to use any other package manager inside bun other than bun? I'm trying to deploy this to docker and wondering if there is a way to still use bun as a runtime. Otherwise I'll have to switch to node entirely :(

ardatan commented 8 months ago

I think you can use npm, yarn or pnpm then run the project using bun.

doloboyz commented 8 months ago

I think you can use npm, yarn or pnpm then run the project using bun.

Second this. This is how I'm currently using bun as well. Once some issues are fixed, prob will migrate to bun as a package manager as well.

XilinJia commented 7 months ago

With version 1.0.18, I got similar errors too. As @ardatan suggested, still having to use yarn is pretty discouraging.

PaulRBerg commented 7 months ago

Update

Oh, I think I have figured out what's going on. Bun is unable to install git dependencies that don't provide a package.json.

I was getting this error:

solarray [2/3] error: InstallFailed extracting taerror: "package.json" for "solarray" failed to open: FileNotFound

The "solarray" repo does not have a package.json file (at the time of posting this comment).

Likewise, the dependency that @doloboyz (OP) wanted to install does not seem to have a package.json file:

https://github.com/uNetworking/uWebSockets.js/tree/750691839587a671653dc1f669fd7e000c6a33d4

Should I open a separate issue to suggest adding support for git dependencies that lack a package.json file?

Initial Report

This is a major issue because it's a blocker. I was excited to move our Node.js projects to Bun instead of Pnpm, but we can't do it because of this issue.

This is the problematic dependency:

"solarray": "github:evmcheb/solarray#0625e7e"

It's a git dependency pulled from GitHub, which can be installed and used just fine with Pnpm or Yarn.

Interestingly, Bun works with this dependency:

"forge-std": "github:foundry-rs/forge-std#v1.5.6",

So there must be something in https://github.com/evmcheb/solarray that troubles Bun. I can't put my finger on what precisely because both that repo and https://github.com/foundry-rs/forge-std are pretty similar in structure (e.g., they both have git submodules).

You can find my full error logs here. Is there any ETA for a fix?

I used Bun v1.0.20

qcasey commented 6 months ago

Changing the dep from ssh git@github.com:qcasey/winston-loki.git to http https://github.com/qcasey/winston-loki.git worked for me 🤷

Bun 1.0.22

amanape commented 6 months ago

Using Bun v1.0.25

Still facing the same issue when trying to run bun add @graphql-mesh/cli graphql

Running bun add uNetworking/uWebSockets.js results in the error error: InstallFailed extracting tarball for uNetworking/uWebSockets.error: "package.json" for "uNetworking/uWebSockets.js" failed to open: FileNotFound

fabianlema commented 6 months ago

Using Bun v1.0.25. It still fails when you run bun install with a dependency like "xxxxx": "git+ssh://git@github.com:xxx/xx.git#xxxxxxx".

cctv1005s commented 4 months ago

Any updates? Still stuck in the error.

skf-funzt commented 4 months ago

Any updates? Still stuck in the error.

Same here, needed to switch to another package manager :disappointed:

medzhidov commented 3 months ago

The same problem, anybody found the solution?

mrguamos commented 3 months ago

Using 1.1.4, still the same

ali-master commented 3 months ago

The same problem with @sinclair/typebox

bun add v1.1.4 (fbe2fe0c)
  🚚 https://registry.npmjs.org [3/3] error: InstallFailed extracting tarball for https://registry.npmjs.org
error: ZlibError decompressing "https://registry.npmjs.org" to ".3fcbbedefffbb7f5-00000001.https://registry.npmjs.org"
ykla commented 2 months ago

The issue also in 1.1.10

ykla@ykla-ubuntu:~/taophilosophy.github.io$ bun -v
1.1.10
Jarred-Sumner commented 1 month ago

The semver protocol is not supported yet for git dependencies. We are planning to add support for that. Keeping this issue open to track the status of that.

Oh, I think I have figured out what's going on. Bun is unable to install git dependencies that don't provide a package.json.

@PaulRBerg this issue has since been fixed as of Bun v1.1.13+

Using Bun v1.0.25. It still fails when you run bun install with a dependency like "xxxxx": "git+ssh://git@github.com:xxx/xx.git#xxxxxxx".

@fabianlema this has been fixed as of Bun v1.1.9 or so

The same problem with @sinclair/typebox

@ali-master were you able to reproduce this issue more than once? It reads like a network error

Same thing with @types/chai error: "git clone" for "@types/chai" failed

@peniqliotuv this should be fixed as of Bun v1.1.13+. Please leave a comment if you still run into it.