oven-sh / bun

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

bun i in workspaces doesn't symlink local dependencies #4830

Open Hebilicious opened 1 year ago

Hebilicious 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?

1) Create a bun workspace with the following config workspaces: ["a", "b"] 2) Add { dependencies: {a: latest }} to b package.json 3) Run bun i

Even if A exists locally, bun will fetch the npm version and install it in /b/node_modules/a

What is the expected behavior?

If one package relies on another, you can simply add it as a dependency with bun add. If package b depends on a, bun install will symlink your local packages/a directory into the node_modules folder of b, instead of trying to download it from the npm registry.

I would expect a to be symlinked instead of fetched from npm.

What do you see instead?

The packages are downloaded instead of being symlinked.

Additional information

Please see this repository as a real world example : https://github.com/Hebilicious/form-actions-nuxt/

If you clone it and run bun i, you will see that packages/playgrounds/simple has a node_modules/@hebilicious/form-actions-nuxt instead of a symlink.

This happens whether @hebilicious/form-actions-nuxt is set to latest or to the current version.

Hebilicious commented 1 year ago

While this issue is related to latest specifically, it looks very similar to https://github.com/oven-sh/bun/issues/4650 and https://github.com/oven-sh/bun/issues/4676

bndkt commented 1 year ago

Can confirm, I'm running into the same issue.

virus2016 commented 1 year ago

Same

nbbaier commented 1 year ago

Running into the same issue as well

bndkt commented 1 year ago

If you reference the dependency using the workspace protocol (e.g. "my-package": "workspace:*") it works. Notice that you have to delete the bun.lockb and run "bun install" for this to take effect. I sent a PR to fix this in the docs (https://github.com/oven-sh/bun/pull/4875).

Hebilicious commented 1 year ago

If you reference the dependency using the workspace protocol (e.g. "my-package": "workspace:*") it works. Notice that you have to delete the bun.lockb and run "bun install" for this to take effect. I sent a PR to fix this in the docs (#4875).

Imo "workspace:*" is a workaround, things should work if you are using latest or the correct version.

@bndkt @nbbaier @virus2016 Please add a 👍🏽 to the first comment, comments like "same" are automatically hidden by GitHub.

nbbaier commented 1 year ago

@bndkt @nbbaier @virus2016 Please add a 👍🏽 to the first comment, comments like "same" are automatically hidden by GitHub.

Done!

Jarred-Sumner commented 2 months ago

@dylan-conway is this a bug or a documentation issue? if this is a documentation issue, can you update the docs?