oven-sh / bun

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

error: failed to save lockfile: AccessDenied #4314

Open k0d3r1s opened 1 year ago

k0d3r1s commented 1 year ago

What version of Bun is running?

0.8.0+9c68abdb8d51951f83b4b253cf5dd3922c2c58b5

What platform is your computer?

Linux 6.1.29-0-virt aarch64 unknown

What steps can reproduce the bug?

I have a basic project, with existing package.json and yarn and this happens on running bun install. It also happens when running bun init or any other bun command that interacts with lockfile.

At first i was thinking that it might be something to do with fact I use volumes in docker but it still happen if i try to write lockfile to /tmp or any other non-volume directory

What is the expected behavior?

Lockfile is created with correct permissions and content is written to it

What do you see instead?

🔒 Saving lockfile... Saving 210 trees Saving 1330 hoisted_dependencies Saving 2308 resolutions Saving 2308 dependencies Saving 90 extern_strings Saving 94000 string_bytes error: failed to save lockfile: AccessDenied


$ ls -lah ---------- 1 root root 0 Aug 25 07:33 bun.lockb


Lockfile is created without any permissions and writing data to it or permission change obviously fails.
I'm not familiar with zig language but I think that issue is at code where you create lockfile and chmod it afterwards.

https://github.com/oven-sh/bun/blob/90f3bf2796b08f38297321c46366ed417b1ecb3b/src/install/lockfile.zig#L1476C5-L1480C7

Additional information

Using docker image oven/bun:canary but still happen with oven/bun:latest as well.

bangbaew commented 1 year ago

Happens to me as well, please let me know if there's any solution

FranklinWaller commented 1 year ago

I'm also struggling getting this to work in a Docker environment. I've created a reproducible environment:

https://github.com/FranklinWaller/bunjs-accesserror

This is using VSCode's devcontainers + Docker to work.

ghost commented 1 year ago

Also encountering this issue with yarn as well.

 [1.52ms] ".env"
2023-09-10 18:08:18 bun install v1.0.0 (822a00c4)
2023-09-10 18:08:19  Saved yarn.lock
2023-09-10 18:08:19 
2023-09-10 18:08:19 error: AccessDenied
motine commented 1 year ago

I had the same issue, I could solve it by telling bun to skip the lockfile: bun install --no-save

dudo commented 11 months ago

I ran into this as well. Oddly enough, the bun.lockb is created - not sure if it's failing to create a package-lock.json, or if the error is erroneous?

I simply have

Dockerfile

FROM oven/bun:1.0

WORKDIR /usr/src/app

ENTRYPOINT [ "bun" ]
CMD [ "help" ]

compose.yml

services:
  bun: &bun
    tty: true
    stdin_open: true
    build:
      context: .
    entrypoint: bun
    command: help
    volumes:
      - .:/usr/src/app:delegated
      - node_modules:/node_modules:cached

volumes:
  node_modules: {}

and I'm running

$ docker compose run --rm bun install

bun install v1.0.6 (969da088)
  🔒 Saving lockfile... error: failed to save lockfile: AccessDenied

Any movement on figuring this out?

dionhut commented 10 months ago

I think this is a dup of https://github.com/oven-sh/bun/issues/4923#issuecomment-1820040043?