oven-sh / bun

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

```bun i``` is not recognizing workspace packages path... #12962

Open crazytweeks opened 1 month ago

crazytweeks commented 1 month ago

What version of Bun is running? 1.1.21

What platform is your computer? Windows 11 Version: 24H2 (26120.961)

What steps can reproduce the bug? run bun install from any monorepo app directory

What is the expected behavior? to use workspaces correctly to resolve packages path from workspace:*

What do you see instead?

bun install v1.1.21 (70ca2b76)
error: Workspace dependency "@flash/icons" not found

Searched in "..\..\..\..\..\E:\bun\flash\apps\portal\*"

Workspace documentation: https://bun.sh/docs/install/workspaces

error: @flash/icons@* failed to resolve

Additional information my workspaces section in package.json file is:

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

          **Issue still persists in bun version 1.1.20 and 1.1.21**

image

bun install works perfectly from root project of monorepo. I am using turborepo

I cannot add any npm packages to any of my sub projects. I need to remove packages with the version "workspace:*" from package.json of that sub application. and run 'bun add '. and then re add those workspace projects manually in package.json, go back to root and re run 'bun i'. This long method works. But its frustrates to manually add packages every time.

image

Why is it searching for package from ..........\E:\bun\flash\apps\portal* On windows, there is no such path. Is there any way i can configure project to look for packages only one or two path above, like '../../**'



@crazytweeks please file a new issue. We will fix it, but what you're seeing is a bug in how we handle Windows file paths, likely related to the E:\ drive letter (as opposed to the C:\ drive letter) and this issue was originally happening in all cases when installing from a subdirectory of a workspace. It would be especially helpful if you can provide a reproduction in the new issue.

Originally posted by @Jarred-Sumner in https://github.com/oven-sh/bun/issues/5413#issuecomment-2259806631

Originally posted by @crazytweeks in https://github.com/oven-sh/bun/issues/5413#issuecomment-2259787993

crazytweeks commented 1 month ago

image image from path '/e/bun/flash' (Which is root of monorepo project)

bun i and bun add zod works fine from root of monorepo project as its adding zod to main package.json file. This also installs packages from paths within "workspaces": ["apps/*", "packages/*"] and "@flash/icons": "workspace:*" will also be installed.


image But i can not install any packages to monorepo apps. from path '/e/bun/flash/apps/portal' (Which is a nextjs app path) bun i and bun add zod will not work until i remove all workspace:* packages from its /e/bun/flash/apps/portal/package.json file.


ONLY WORKAROUND THAT HELPED ME

Remove Press ctrl+x[Copy to clipboard and remove] lines of workspace:* packages from monorepo application where you need to add packages. Now run bun add zod or whatever add you want to do... Next go back to package.json file and add the copied lines back in dependencies/devDependencies. Go back to root of monorepo. Now again run bun i

As this same issue was maybe resolved in previous versions, maybe its broken again or this may be the issue from windows machine.

crazytweeks commented 1 month ago

Same issue in Bun 1.1.24 also...