oven-sh / bun

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

Error with workspace dependency resolution when adding new packages #10889

Open AlandSleman opened 1 week ago

AlandSleman commented 1 week ago

What version of Bun is running?

1.1.7

What platform is your computer?

Linux 6.8.0-76060800daily20240311-generic x86_64 x86_64

What steps can reproduce the bug?

  1. clone the workspaces example repo https://github.com/AlandSleman/bun-workspace-issue
  2. create a new package
  3. add the new package as a dependency for any other packages and run bun install

What is the expected behavior?

All workspace dependencies, including newly added packages, should be correctly resolved and installed without errors.

What do you see instead?

Instead of the expected smooth dependency resolution and installation, the following issues are observed:

  1. After running bun install An error message indicating that the workspace dependency @oven-sh/c is not found, despite it being correctly defined in the package.json of another package within the workspace.

    error: workspace dependency "@oven-sh/c" not found
    Searched in "./*"
  2. After running bun install --verbose a verbose log message suggesting an issue with file operations, specifically mentioning difficulties with moving files from a temporary directory due to restrictions across mount points:

    info: cannot move files from tempdir: RenameAcrossMountPoints, using fallback

These issues suggest problems with Bun's handling of local workspace dependencies and potentially its file system operations in certain environments, leading to unsuccessful installations and unresolved dependencies.

Additional information

A repository demonstrating the issue: https://github.com/AlandSleman/bun-workspace-issue

AlandSleman commented 1 week ago

After diving deeper, I think the issue is with the * wildcard, after explicitly specifying the workspaces/packages in the package.json.

So instead of using:

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

You could specify:

  "workspaces": [
    "apps/backend",
    "packages/backend-api"
  ],

After explicitly defining packages and installing the packages, the * wildcard does work correctly for including all packages and apps. I'm keeping this issue open because there could be an underlying issue with the * wildcard when configuring packages/workspaces, I also think it involves caching. Please correct me if I'm wrong.