oven-sh / bun

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

bun add enoent #7042

Closed bazo closed 4 months ago

bazo commented 1 year ago

What version of Bun is running?

1.0.11+f7f6233ea

What platform is your computer?

Darwin 23.0.0 arm64 arm

What steps can reproduce the bug?

bun add final-form react-final-form

What is the expected behavior?

it installs

What do you see instead?

bun add v1.0.11 (f7f6233e)

error: ENOENT

----- bun meta ----- Bun v1.0.11 (f7f6233e) macOS Silicon 23.0.0 AddCommand: Elapsed: 15ms | User: 10ms | Sys: 13ms RSS: 20.87MB | Peak: 20.87MB | Commit: 34.62MB | Faults: 243 ----- bun meta -----

0 0x1058bbe44 1 ???

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord

Additional information

i have a monorepo with two folders/packages client and server

sometimes when i try adding something in client i get this error some packages install ok

i started the project today, so i don't know if it worked ok before :)

if i add the packages manually into package.json then run bun i it installs fine

arn4v commented 12 months ago

I'm running into the same issue.

bun add v1.0.11 (f7f6233e)

error: ENOENT

----- bun meta -----
Bun v1.0.11 (f7f6233e) macOS Silicon 23.0.0
AddCommand: 
Elapsed: 15ms | User: 10ms | Sys: 10ms
RSS: 21.68MB | Peak: 21.68MB | Commit: 34.62MB | Faults: 243
----- bun meta -----

0   0x101393e44
1   ???
Jarred-Sumner commented 12 months ago

This is fixed in Bun v1.0.12. Please run bun upgrade --canary to get it now or wait about an hour and run bun upgrade

In the meantime, try deleting package-lock.json.

adicco commented 12 months ago

Still running into this in Bun v1.0.12:

➜  server git:(main) ✗ bun add @picocss/pico@next
bun add v1.0.12 (85c99751)

error: ENOENT

----- bun meta -----
Bun v1.0.12 (85c99751) Linux x64 #6 SMP PREEMPT_DYNAMIC Fri Oct 13 22:06:56 UTC 2023
AddCommand: 
Elapsed: 7ms | User: 7ms | Sys: 7ms
RSS: 36.71MB | Peak: 27.53MB | Commit: 36.71MB | Faults: 0
----- bun meta -----

0   0x56134206120b
1   ???
2   ???
3   ???
4   ???
5   ???
6   ???

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord

FWIW bun add is run in a packages/server workspace

dylan-conway commented 12 months ago

@adicco is there a package-lock.json in your workspace package or the root package?

adicco commented 12 months ago

@adicco is there a package-lock.json in your workspace package or the root package?

Only a bun.lockb one at the root level.

lambdaiv commented 11 months ago

This is still an issue with v1.0.13 as well.

❯ bun add playwright-core

bun add v1.0.13 (f5bf67bd)

error: ENOENT

----- bun meta -----
Bun v1.0.13 (f5bf67bd) macOS x64 23.1.0
AddCommand: 
Elapsed: 10ms | User: 18ms | Sys: 9ms
RSS: 16.87MB | Peak: 16.87MB | Commit: 34.61MB | Faults: 0
----- bun meta -----

0   0x108308040

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord
adicco commented 11 months ago

Same here, I will paste the output log when it occurs again. It seems to only happen when I bun add inside one of the workspace's packages, although it doesn't happen all the time.

A workaround is to delete the node_modules folder and bun.lockb file, and try again, which usually works. If not, I've had to bun add at the root level of the workspace, and then manually pick the dependency from the root package.json and move it to the right folder in the packages directory. Usually I do a full clean (rm all node_modules and bun.lockb files) and bun install again and it works. Cumbersome but at least I can install deps.

paulleonartcalvo commented 11 months ago

Also encountered this when running add from within a workspace in v1.0.14. Only a bun.lockb at the root of the monorepo

vrn-dev commented 11 months ago

Facing the same issue here on WSL2 Ubuntu 22.04 with bun 1.0.14+d8be3e51b. Happens on both add and remove command

EDIT: I changed the workspace package ref in package.json to a relative path, and it started working:

Was:

{
  "name": "@pkg/abc",
  "module": "src/index.ts",
  "type": "module",
  "scripts": {
    "dev": "bun run --watch src/index.ts"
  },
  "devDependencies": {
    "bun-types": "latest",
    "typescript": "^5.3.2"
  },
  "dependencies": {
    "@pkg/utils": "workspace:*",
  }
}

Changed to:

{
  "name": "@pkg/abc",
  "module": "src/index.ts",
  "type": "module",
  "scripts": {
    "dev": "bun run --watch src/index.ts"
  },
  "devDependencies": {
    "bun-types": "latest",
    "typescript": "^5.3.2"
  },
  "dependencies": {
    "@pkg/utils": "workspace:../../common/utils",
  }
}
lambdaiv commented 11 months ago

Yeah, it seems to be an issue for me when I run a second bun add ... right after the first one. I can delete the bun.lockb file and the install works again temporarily.

❯ bun add oppossum  
bun add v1.0.14 (d8be3e51)

error: ENOENT

----- bun meta -----
Bun v1.0.14 (d8be3e51) macOS x64 23.1.0
AddCommand: 
Elapsed: 14ms | User: 21ms | Sys: 10ms
RSS: 17.30MB | Peak: 17.30MB | Commit: 34.61MB | Faults: 15
----- bun meta -----

0   0x107638860

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord
sean256 commented 11 months ago

Still an issue with bun v1.0.15 Like the others, the first sub package install works, then subsequent installs fail. Nuking the lock file fixes it. I also found that installing the desired package in root, then removing it, then adding it in the sub package is a workaround.

roguesherlock commented 10 months ago
❯ bun add "next-themes"
bun add v1.0.18 (36c316a2)

error: ENOENT

----- bun meta -----
Bun v1.0.18 (36c316a2) macOS Silicon 23.1.0
AddCommand: 
Elapsed: 4ms | User: 9ms | Sys: 7ms
RSS: 20.46MB | Peak: 20.46MB | Commit: 34.62MB | Faults: 0
----- bun meta -----

0   0x1039bc1e0
1   ???

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord

I'm also facing the same issue when I try to add a package in the sub package in my monorepo setup. It works fine if I add it to the root package. It's only when you try to run bun add in the sub packages that you get this error.

tgrushka commented 8 months ago

This is most definitely not fixed. When a package fails to install, it logs Error: ENOENT install ... but returns exit code 0.

Terrible that bun always returns 0 so you can't rely on it in CI pipelines or container builds. This should be an easy fix.

sean256 commented 8 months ago

This is most definitely not fixed. When a package fails to install, it logs Error: ENOENT install ... but returns exit code 0.

Terrible that bun always returns 0 so you can't rely on it in CI pipelines or container builds. This should be an easy fix.

Thankfully this bug only happens when adding modules to sub packages, which isn't something you're doing in a CI pipeline.

bazo commented 8 months ago

yeah, still happens with latest bun even for bun remove, not just bun add

[0.34ms] ".env"
bun remove v1.0.29 (a146856d)

error: FileNotFound
Bun could not find a file, and the code that produces this error is missing a better error.

----- bun meta -----
Bun v1.0.29 (a146856d) macOS Silicon 23.2.0
RemoveCommand: dotenv 
Elapsed: 8ms | User: 12ms | Sys: 6ms
RSS: 22.32MB | Peak: 22.30MB | Commit: 34.62MB | Faults: 0
----- bun meta -----

this is the only bug keeping me from switching my work project to bun. and it's getting really annoying in personal projects too.

dylan-conway commented 4 months ago

This was fixed in bun v1.1.9 with #11177, closing as complete. Please reopen or create a new issue if you continue to have issues with bun workspaces