bun icon indicating copy to clipboard operation
bun copied to clipboard

workspace packages list gets stale if new workspace packages are depended on

Open scinos opened this issue 2 years ago • 14 comments

What version of Bun is running?

v0.6.15 (17903570)

What platform is your computer?

Darwin 21.6.0 arm64 arm

What steps can reproduce the bug?

Create a file package.json with:

{
  "name": "bun-workspaces",
  "module": "index.ts",
  "type": "module",
  "workspaces": [
    "packages/a"
  ],
  "dependencies": {
    "a": "workspace:^"
  }
}

Create a second file packages/a/package.json with:

{
  "name": "a",
  "version": "1.0.0"
}

Then run bun install in the root.

What is the expected behavior?

It creates a node_moudules with a symlinked to packages/a.

What do you see instead?

Error

error: Workspace name "a" already exists
{
^

Additional information

As a workaround, replacing workspace:^ with workspace:* works.

For reference, these are the semantics of the workspace: protocol in yarn and pnpm.

image

scinos avatar Jul 19 '23 21:07 scinos

I have a different issue around workspaces, I get

error: workspace dependency "@techstack/tcm-cli" not found

Searched in "./*"

This happens on bun install

The-Code-Monkey avatar Sep 14 '23 15:09 The-Code-Monkey

I have a different issue around workspaces, I get

error: workspace dependency "@techstack/tcm-cli" not found

Searched in "./*"

This happens on bun install

This was working fine for me until I ran bun clean. Then I started getting the same error as above when running bun install.

I have

  "workspaces": [
    "apps/*",
    "packages/*"
  ]

in my package.json.

potrepka avatar Sep 16 '23 08:09 potrepka

@potrepka I'm glad it's not just me who's getting this

The-Code-Monkey avatar Sep 16 '23 10:09 The-Code-Monkey

I have a different issue around workspaces, I get

error: workspace dependency "@techstack/tcm-cli" not found

Searched in "./*"

This happens on bun install

Getting this issue as well, not sure what's going on. Following everything in the docs, trying to port over from pnpm to bun as a package manager but this is kind of a roadblock atm.

cnrad avatar Sep 16 '23 23:09 cnrad

Same issue. To reproduce:

  1. git clone https://github.com/gitcoinco/grants-stack
  2. add a workspaces: ["packages/*"] to the root package.json
  3. bun install in root
  4. observe the error
error: workspace dependency "common" not found

Searched in "./*"

vacekj avatar Sep 19 '23 07:09 vacekj

The same issue for me :(

P.S. Just tried it with pnpm and pnpm-workspace.yaml and everything works fine

akodkod avatar Sep 19 '23 22:09 akodkod

I'm also getting this error `error: workspace dependency "some_package" not found

Searched in "./*"`

package.json is correctly configured with "packages/*", also tried specifying the packages individually, didn't work.

Coming from pnpm workspaces, I had no such issue there.

kobibasson avatar Sep 21 '23 08:09 kobibasson

I got it to work by deleting the bun.lockb file and running bun install again.

It appears to happen sporadically. I'm not sure what's going wrong under the hood. Also had no such issue with pnpm.

menno-lab avatar Sep 21 '23 10:09 menno-lab

getting the same issue, any updates?

artrixdotdev avatar Sep 24 '23 18:09 artrixdotdev

I think all errors error: workspace dependency not found are a different error than the original one. This issue is specifically about using the qualifier ^ for the workspace: protocol.

If you are getting error: workspace dependency not found chances are you are hitting a different error. I'll be happy to help diagnose it, but you need to include your package.json for both the consumer and the missing workspace dependency.

scinos avatar Sep 24 '23 19:09 scinos

I got it to work by deleting the bun.lockb file and running bun install again.

It appears to happen sporadically. I'm not sure what's going wrong under the hood. Also had no such issue with pnpm.

this really helped! thanks

also, my 2 cents here, I noticed that every time I create a new package inside the workspace packages/* and try to install this as a dependency of any other module, it keeps throwing the error, I'm thinking that it has something to do with bun binary that is not being able to "update" or something like that, like it's trying to resolve dependencies as the older state that didn't had information about the latest package module. After deleting bun.lockb file and trying to install it works perfectly.

This looks like it only is a problem for the first module that tries to install the new package, something like:

  • Create a new module inside packages/*
  • Try to install as a dependency from another module, it breaks
  • Remove bun.lockb
  • Try to install again and it should work
  • Try to add the same package as dependency to another module
  • bun install works without having to delete bun.lockb again

if i try to remove a package from dependencies and then bun install, it works as expected, so it seems that it's only for newly created packages added as dependency for the first time

vitoorgomes avatar Sep 26 '23 11:09 vitoorgomes

Confirming this is not fixed as of Bun v1.0.11

The bug is not specifically related to the workspace version specifier. It is due to not updating the list of workspace_versions and workspace package names on each run, which causes the list to get stale

reproduction.zip

Jarred-Sumner avatar Nov 15 '23 07:11 Jarred-Sumner

Do we know when this will be fixed?

On Wed, 15 Nov 2023, 07:48 Jarred Sumner, @.***> wrote:

Confirming this is not fixed as of Bun v1.0.11

The bug is not specifically related to the workspace version specifier. It is due to not updating the list of workspace_versions and workspace package names on each run, which causes the list to get stale

reproduction.zip https://github.com/oven-sh/bun/files/13361754/worky1.zip

— Reply to this email directly, view it on GitHub https://github.com/oven-sh/bun/issues/3686#issuecomment-1811958849, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHOFWX4CZZCP5H2QPWHC5K3YERXWLAVCNFSM6AAAAAA2QQPGHCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJRHE2TQOBUHE . You are receiving this because you commented.Message ID: @.***>

The-Code-Monkey avatar Nov 16 '23 06:11 The-Code-Monkey

Getting same error on 1.0.22, if I delete bun.lockb then bun install works again but I have to remove after I install a new package or if a added a new folder under the directories listed on workspaces: [] package.json array.

xantiagoma avatar Jan 17 '24 04:01 xantiagoma

This issue was fixed around ~1.0.10 and this comment was likely fixed in #11177 . Going to close this as fixed, please reopen or open a new issue if you continue to have issues with installing workspace packages.

dylan-conway avatar May 25 '24 03:05 dylan-conway