Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scinos opened this issue Jul 19, 2023 · 15 comments
Closed
Assignees
Labels
bug Something isn't working npm Something that relates to the npm-compatible client

Comments

@scinos
Copy link

scinos commented Jul 19, 2023

What version of Bun is running?

v0.6.15 (1790357)

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 scinos added the bug Something isn't working label Jul 19, 2023
@robobun robobun added the npm Something that relates to the npm-compatible client label Jul 19, 2023
@The-Code-Monkey
Copy link

I have a different issue around workspaces, I get

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

Searched in "./*"

This happens on bun install

@potrepka
Copy link

potrepka commented Sep 16, 2023

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.

@The-Code-Monkey
Copy link

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

@cnrad
Copy link

cnrad commented Sep 16, 2023

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.

@vacekj
Copy link

vacekj commented Sep 19, 2023

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 "./*"

@akodkod
Copy link

akodkod commented Sep 19, 2023

The same issue for me :(

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

@kobibasson
Copy link

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.

@menno-lab
Copy link

menno-lab commented Sep 21, 2023

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.

@Artrix9095
Copy link

getting the same issue, any updates?

@scinos
Copy link
Author

scinos commented Sep 24, 2023

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.

@vitoorgomes
Copy link

vitoorgomes commented Sep 26, 2023

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

@Jarred-Sumner Jarred-Sumner changed the title workspace:^ is not working workspace: packages list gets stale if new workspace packages are depended on Nov 15, 2023
@Jarred-Sumner Jarred-Sumner changed the title workspace: packages list gets stale if new workspace packages are depended on workspace packages list gets stale if new workspace packages are depended on Nov 15, 2023
@Jarred-Sumner
Copy link
Collaborator

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

@The-Code-Monkey
Copy link

The-Code-Monkey commented Nov 16, 2023 via email

@xantiagoma
Copy link

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.

@dylan-conway
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working npm Something that relates to the npm-compatible client
Projects
None yet
Development

No branches or pull requests