oven-sh / bun

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

Package install "renaming" doesn't work with Bun install #4899

Open byCedric opened 1 year ago

byCedric commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

The full description of the issue can be found here: https://github.com/isaacs/jackspeak/issues/5#issuecomment-1532498370

TL;DR; With npm, you can use different values other than a semver range in your package.json for your dependencies. That includes prefixes such as github:<owner>/<repo>, file:<path-to-workspace>, or even npm:<some-package>@<semver-range>. This kind of works already, with the exception of "renaming".

When you install the @isaacs/cliui@8.0.2 package, that uses the code below as dependencies, Bun seems to fail without fully breaking.

{
  "dependencies": {
    "string-width": "^5.1.2",
    "string-width-cjs": "npm:string-width@^4.2.0",
    "strip-ansi": "^7.0.1",
    "strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
    "wrap-ansi": "^8.1.0",
    "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
  }
}

What is the expected behavior?

Bun should install string-width@5.1.2 as node_modules/string-width and string-width@4.2.0 as node_modules/string-width-cjs.

What do you see instead?

Bun outputs error: PathAlreadyExists installing string-width in this case.

image

(source: https://github.com/expo/vscode-expo/actions/runs/6138072599/job/16654576302#step:3:51)

Additional information

The full description of the issue can be found here: https://github.com/isaacs/jackspeak/issues/5#issuecomment-1532498370

Jarred-Sumner commented 4 months ago

@dylan-conway this was fixed in v1.1.6 right?

webpro commented 2 months ago

Just adding more details, maybe this helps.

Same odd issue here, I can't reproduce locally, but it consistently fails in GitHub Actions. Same, latest version: Bun v1.1.20.

Again, here's the package.json of @isaacs/cliui (21M downloads/week btw):

https://github.com/isaacs/cliui/blob/aa397fedbd0550c9925af6b62f970de663285641/package.json#L51-L58

  "dependencies": {
    "string-width": "^5.1.2",
    "string-width-cjs": "npm:string-width@^4.2.0",
    "strip-ansi": "^7.0.1",
    "strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
    "wrap-ansi": "^8.1.0",
    "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
  },

Looks like "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" is resolved to wrap-ansi-cjs@^7.0.0 which does not exist (this goes for all -cjs packages here.

On my machine (wtf?):

❯ bun add wrap-ansi-cjs@^7.0.0
bun add v1.1.20 (ae194892)

installed wrap-ansi-cjs@7.0.0

[132.00ms] done

Versions of wrap-ansi-cjs on npm: https://www.npmjs.com/package/wrap-ansi-cjs?activeTab=versions

In CI, this consistently fails:

https://github.com/webpro-nl/knip/actions/runs/9921011085/job/27418480569

Run bun install --ignore-scripts --frozen-lockfile
  bun install --ignore-scripts --frozen-lockfile
  shell: /bin/bash -e {0}
bun install v1.1.20 (ae194892)
error: GET https://registry.npmjs.org/strip-ansi-cjs/-/strip-ansi-cjs-6.0.1.tgz - 404

error: GET https://registry.npmjs.org/string-width-cjs/-/string-width-cjs-4.2.3.tgz - 404

error: GET https://registry.npmjs.org/wrap-ansi-cjs/-/wrap-ansi-cjs-7.0.0.tgz - 404
webpro commented 2 months ago

Did some tests and fairly certain it's an issue/regression with generating the lockfile and then installing with the same Bun v1.1.20.