owenizedd / bum

Bum - Bun Version Manager ⚡
131 stars 1 forks source link

[macOS arm64] Installation via `bum use` fails with `Reason: No such file or directory (os error 2)` #23

Open kavsingh opened 3 months ago

kavsingh commented 3 months ago

Re-trying bum on macOS arm64 after https://github.com/owenizedd/bum/issues/14#issuecomment-2247866356

os: macOS 14.5 (23F79) chip: M3 Max

installing bum went well

❯ curl -fsSL https://github.com/owenizedd/bum/raw/main/install.sh | bash
######################################################################## 100.0%
x bum-v0.6.1-aarch64-apple-darwin/
x bum-v0.6.1-aarch64-apple-darwin/bum
bum was installed successfully to  /[$HOME]/.bum/bin/bum

~/.zshrc was successfully updated:

# bum
export BUM_INSTALL="$HOME/.bum"
export PATH="$BUM_INSTALL/bin:$PATH"

looked up latest available bun version, all good

❯ bum list-remote
  v1.1.21
  v1.1.20
  v1.1.19
  v1.1.18
  v1.1.17
  v1.1.16
  v1.1.15
  v1.1.14
  v1.1.13
  v1.1.12
  v1.1.11
  v1.1.10
  ...

however attempting to install a bun version failed

without the v

❯ bum use 1.1.21
Bum - installing bun for version 1.1.21...
Extracting zip file...
Failed Err(No such file or directory (os error 2))

with the v

❯ bum use v1.1.21
Bum - installing bun for version 1.1.21...
Extracting zip file...
Failed Err(No such file or directory (os error 2))

with backtrace

❯ RUST_BACKTRACE=1 bum use 1.1.21
Failed to activate Bun v1.1.21
Reason: No such file or directory (os error 2)

Stack backtrace:
   0: std::backtrace::Backtrace::create
   1: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   2: bum::commands::activate_bun::{{closure}}
   3: bum::commands::use_bun::{{closure}}
   4: bum::run_commands::{{closure}}
   5: tokio::runtime::park::CachedParkThread::block_on
   6: tokio::runtime::context::runtime::enter_runtime
   7: tokio::runtime::runtime::Runtime::block_on
   8: bum::main
   9: std::sys_common::backtrace::__rust_begin_short_backtrace
  10: std::rt::lang_start::{{closure}}
  11: std::rt::lang_start_internal
  12: _main

looking into $HOME/.bum

❯ ls -lahR ~/.bum
total 0
drwxr-xr-x   4 [my user]  staff   128B Jul 27 14:15 .
drwxr-x---+ 71 [my user]  staff   2.2K Jul 27 14:41 ..
drwxr-xr-x   3 [my user]  staff    96B Jul 27 14:15 bin
drwxr-xr-x   5 [my user]  staff   160B Jul 27 14:37 bun-versions

/$HOME/.bum/bin:
total 10272
drwxr-xr-x  3 [my user]  staff    96B Jul 27 14:15 .
drwxr-xr-x  4 [my user]  staff   128B Jul 27 14:15 ..
-rwxr-xr-x  1 [my user]  staff   5.0M Jul 24 14:36 bum

/$HOME/.bum/bun-versions:
total 0
drwxr-xr-x  5 [my user]  staff   160B Jul 27 14:37 .
drwxr-xr-x  4 [my user]  staff   128B Jul 27 14:15 ..
drwxr-xr-x  3 [my user]  staff    96B Jul 27 14:37 1.1.19
drwxr-xr-x  3 [my user]  staff    96B Jul 27 14:37 1.1.20
drwxr-xr-x  3 [my user]  staff    96B Jul 27 14:19 1.1.21

/$HOME/.bum/bun-versions/1.1.19:
total 107624
drwxr-xr-x  3 [my user]  staff    96B Jul 27 14:37 .
drwxr-xr-x  5 [my user]  staff   160B Jul 27 14:37 ..
-rw-r--r--  1 [my user]  staff    53M Jul 27 14:37 bun

/$HOME/.bum/bun-versions/1.1.20:
total 107624
drwxr-xr-x  3 [my user]  staff    96B Jul 27 14:37 .
drwxr-xr-x  5 [my user]  staff   160B Jul 27 14:37 ..
-rw-r--r--  1 [my user]  staff    53M Jul 27 14:37 bun

/$HOME/.bum/bun-versions/1.1.21:
total 106056
drwxr-xr-x  3 [my user]  staff    96B Jul 27 14:19 .
drwxr-xr-x  5 [my user]  staff   160B Jul 27 14:37 ..
-rw-r--r--  1 [my user]  staff    52M Jul 27 14:19 bun

~
❯ find ~/.bum -type f
/$HOME/.bum/bin/bum
/$HOME/.bum/bun-versions/1.1.20/bun
/$HOME/.bum/bun-versions/1.1.19/bun
/$HOME/.bum/bun-versions/1.1.21/bun

~
❯ ls -la ~/.bum/bin/bum
-rwxr-xr-x  1 [my user]  staff  5258312 Jul 24 14:36 /$HOME/.bum/bin/bum

~
❯ ls -la ~/.bum/bun-versions/1.1.21/bun
-rw-r--r--  1 [my user]  staff  54298016 Jul 27 14:19 /$HOME/.bum/bun-versions/1.1.21/bun

also happens when attempting older versions of bun

❯ RUST_BACKTRACE=1 bum use 1.1.19
Bum - installing bun for version 1.1.19...
Extracting zip file...
Failed Err(No such file or directory (os error 2)

Stack backtrace:
   0: std::backtrace::Backtrace::create
   1: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   2: bum::commands::activate_bun::{{closure}}
   3: bum::commands::use_bun::{{closure}}
   4: bum::run_commands::{{closure}}
   5: tokio::runtime::park::CachedParkThread::block_on
   6: tokio::runtime::context::runtime::enter_runtime
   7: tokio::runtime::runtime::Runtime::block_on
   8: bum::main
   9: std::sys_common::backtrace::__rust_begin_short_backtrace
  10: std::rt::lang_start::{{closure}}
  11: std::rt::lang_start_internal
  12: _main)
kavsingh commented 3 months ago

note that bum remove works despite versions not activated

~
❯ echo $BUM_INSTALL
/[$HOME]/.bum

~
❯ bum remove 1.1.21
"/[$HOME]/.bum/bun-versions/1.1.21"
v1.1.21 has been removed.

~
❯ bum remove 1.1.19
"/[$HOME]/.bum/bun-versions/1.1.19"
v1.1.19 has been removed.

~
❯ bum list
thread 'main' panicked at src/bun.rs:21:10:
Failed to execute bun -v, is bun installed?: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

~
❯ bum remove 1.1.20
"/[$HOME]/.bum/bun-versions/1.1.20"
v1.1.20 has been removed.

~
❯ ls ~/.bum/bun-versions

~
❯

but then no dice trying to re-install after remove

~
❯ bum use v1.1.21
Bum - installing bun for version 1.1.21...
Extracting zip file...
Failed Err(No such file or directory (os error 2))

~
❯ ls ~/.bum/bun-versions
1.1.21

~
❯
kavsingh commented 3 months ago

it seems to be to do with the usage of BUN_BIN_PATH: https://github.com/owenizedd/bum/blob/67953aac17b7f98ac8a616eddfd6386e1cf14251/src/commands.rs#L87

the folder "~/.bun/bin" does not exist on my system and does not seem to be created in install.sh

note - i removed my brew installation of bun before retrying bum, so that might have taken out ~/.bun. in any case, the same issue would probably affect anyone who hasn't installed bun before.

i guess there would have to be a exists-or-create step similar to https://github.com/owenizedd/bum/blob/67953aac17b7f98ac8a616eddfd6386e1cf14251/src/commands.rs#L66

or install.sh should create the folder (and add .bun/bin to path in shell profile)?

i tried modifying the code locally to ensure the folder and it seemed to work

❯ bum use v1.1.21
bun used path "/$HOME/.bum/bun-versions/1.1.21/bun"
bun bin path "/$HOME/.bun/bin/bun"
no folder "/$HOME/.bun/bin", creating
Bun v1.1.21 is activated.
owenizedd commented 3 months ago

I see that makes sense it might happen if the folder doesn’t exist but bun is available during installation, another solution is if bun is available but folder is not there than create it during installation script.

Do you want to raise PR for the fix?

h2oearth commented 1 month ago

The installation script is still broken on my end :-/. Thanks to @kavsingh for the fix!