bun
bun copied to clipboard
bun install dependencies of os incompatible optionalDependencies
Version
0.1.10
Platform
Mac intel
What steps will reproduce the bug?
bun add @swc/core
What is the expected behavior?
node_modules
@swc
core
package.json
core-darwin-x64
package.json
What do you see instead?
node_modules
@swc
core
package.json
core-android-arm-eabi
node_modules
@swc
wasm
package.json
core-darwin-x64
package.json
wasm
package.json
Can you try canary build? It can be because missing os implementation in stable version.
Same issue with canary.
bun ignore installing packages for other os/cpu. but the issue is that the dependencies of these skipped package are still installed. You can see that these is no package.json for core-android-arm-eabi
This is not a common use case, often packages with these conditions are "leaf" of the dependency tree (this is the case for esbuild or parcel css)
I think (?) this is the same problem -- using bun 0.1.3 on linux x86_64:
here's a minimal reproduction:
$ cat package.json
{"dependencies": {"chokidar": "*"}}
$ bun install --yarn
bun install v0.1.13
+ [email protected]
14 packages installed [693.00ms]
this creates a yarn lockfile that has incorrect dependencies:
$ rm -rf node_modules
$ yarn install
yarn install v1.22.19
warning package.json: No license field
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
error [email protected]: The platform "linux" is incompatible with this module.
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
the difference between the lockfiles appears to be handling of optionalDependencies:
$ diff -u <(sed 's/tgz#.*"/tgz"/g' yarn.lock) yarn.lock.bun
--- /dev/fd/63 2022-09-20 11:15:59.289446454 -0400
+++ yarn.lock.bun 2022-09-20 11:13:57.065443600 -0400
@@ -1,5 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
+# bun ./bun.lockb --hash: 678F5BC3C2B30D95-fe2de4c5fdc85003-83B2DE77992FC7A0-2a5d090942fac8b9
anymatch@~3.1.2:
@@ -34,7 +35,6 @@
is-glob "~4.0.1"
normalize-path "~3.0.0"
readdirp "~3.6.0"
- optionalDependencies:
fsevents "~2.3.2"
fill-range@^7.0.1:
so I started looking into this -- the yarn printer seems like it should handle this -- or at least there's code for it. that would make me think that the actual resolution is incorrect? or something earlier?
https://github.com/oven-sh/bun/blob/0873a15a637339506207fe9bd628e2839d78dbbc/src/install/lockfile.zig#L1313-L1315
The intended current behavior is they appear in the lockfile and are resolved, but are not actually downloaded/installed to disk. This is so if people working on the project have different hardware/os, the lockfile doesn’t change.
If they are being downloaded/installed to disk anyway, that is indeed a bug and from the first directory tree shown that is what seems to be happening
I guess my usecase is a little weird: I want to incrementally introduce bun -- first as an installer in CI (where it is way faster than yarn) -- but in order to do that gradual step I need to not break yarn (since there's still some special stuff that only works there). since optionalDependencies isn't preserved correctly in the yarn lockfile it breaks any dev still using yarn (even if bun correctly installs)
This is fixed as of Bun 0.5.8.
❯ bun add @swc/core
bun add v0.5.8 (5d296f62)
installed @swc/[email protected]
2 packages installed [817.00ms]
❯ ls node_modules/@swc
core/ core-darwin-arm64/
@Electroid do you have a specific link to the fix? I'm not seeing it working with 0.5.7 (the currently released version):
$ bun install --yarn
bun install v0.5.7 (5929daee)
+ [email protected]
14 packages installed [375.00ms]
$ rm -rf node_modules/
$ yarn install
yarn install v1.22.19
warning package.json: No license field
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
error [email protected]: The platform "linux" is incompatible with this module.
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
@asottile-sentry Oops, forgot I was on our canary build when testing this. Could you try again after running: bun upgrade --canary? If you're running into the same issue will re-open.
@asottile-sentry I think the issue you're running into is in the yarn lockfile printer. It should report that the fsevents module is an optional dependency but it isn't. That is a different issue than installing the module.
Regardless though, we would love for Sentry to use Bun and we will prioritize making it work for your usecase.
sounds good -- will follow #2216! (fwiw the --canary also failed in the same way)