oven-sh / bun

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

`bun create` uses the latest locally cached version even when the `@latest` tag is provided #4981

Closed 0xOlias closed 8 months ago

0xOlias commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Darwin 21.6.0 arm64 arm

What steps can reproduce the bug?

  1. Install any create-thing package at a specific (non-latest) version
  2. Run bun create thing@latest

Bun will use the latest cached version instead of checking the registry, which I think is very unexpected.

kevinkoste temp % bun install create-vite@4.3.0
bun add v1.0.0 (822a00c4)

 installed create-vite@4.3.0 with binaries:
  - create-vite
  - cva

 1 packages installed [1442.00ms]
kevinkoste temp % bun create vite@latest
✔ Project name: … test-project
✔ Select a framework: › Vanilla
✔ Select a variant: › JavaScript

Scaffolding project in /Users/kevinkoste/workspace/temp/test-project...

Done. Now run:

  cd test-project
  bun install
  bun run dev

kevinkoste test-project % cat test-project/package.json
{
  "name": "test-project",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "devDependencies": {
    "vite": "^4.3.0"
  }
}

What is the expected behavior?

For reference, here's my understanding of how the other package managers handle this:

Bun's current behavior is most similar to npm, except Bun does not fetch the latest version from the registry even if you specify it. I'm guessing this is just a bug and would be a quick fix, but I'd like to propose a step futher:

IMO, Bun should (by default) behave like pnpm - if the user does not specify a tag, download and use the latest version from the registry when using the bun create shortcut. It would also be lovely to log a "Using create-vite@4.4.1" line similar to what bun install produces. This would save a lot of headache and bug reports for authors of create-* packages like myself.

What do you see instead?

No response

Additional information

No response

MatyiFKBT commented 1 year ago

This should be fixed in https://github.com/oven-sh/bun/pull/5346

dufu1991 commented 1 year ago

I have just updated bun to version 1.0.2, but when I run bunx create-stdf@latest, it still doesn't use the latest version and instead uses the cached version.

ytkg commented 1 year ago

me too.

shawnlikescode commented 1 year ago

I still have this issue with bunx @latest on bun version 1.0.2 as well.

I have just updated bun to version 1.0.2, but when I run bunx create-stdf@latest, it still doesn't use the latest version and instead uses the cached version.

dufu1991 commented 1 year ago

I still hope that the command bun create has the same logic as pnpm and uses the latest version directly when it is not specified, which is a much-needed feature.