oven-sh / bun

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

[BUG] Can't upgrade bun on windows if its install directory is symlinked to another drive #15279

Open EDM115 opened 2 days ago

EDM115 commented 2 days ago

What version of Bun is running?

1.1.34-canary.51+5e5e7c60f

What platform is your computer?

Microsoft Windows NT 10.0.22635.0 x64

What steps can reproduce the bug?

  1. Install bun (using powershell -c 'irm bun.sh/install.ps1 | iex')
  2. Move the bun install directory to another drive (on a cmd, I did cd %USERPROFILE% && mklink /D ".bun" "D:\EDM115\UserFiles\.bun")
  3. Wait for an update to come
  4. Try to update : bun upgrade

What is the expected behavior?

Bun should be able to update itself regardless of the drive it's present on

What do you see instead?

bun upgrade
error: Failed to move new version of Bun to D:\EDM115\UserFiles\.bun\bin\bun.exe to EPERM

Please reinstall Bun manually with the following command:
   powershell -c 'irm bun.sh/install.ps1|iex'

Additional information

No response

heimskr commented 14 hours ago

After some investigation, it seems the issue isn't with symlinks but with renaming across drives. (I was able to upgrade if the symlink pointed to somewhere on the same drive, but not if it pointed to a different drive.) For renaming things on Windows, we ultimately call NtSetInformationFile, which disallows renaming across drives. To fix this we'll have to change how we rename files.