Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bun sudo option? bun doesnt upgrade without it if installed on /usr/bin(from aur) #892

Open
4 tasks
littleblack111 opened this issue Aug 26, 2024 · 20 comments · May be fixed by #894
Open
4 tasks

Add bun sudo option? bun doesnt upgrade without it if installed on /usr/bin(from aur) #892

littleblack111 opened this issue Aug 26, 2024 · 20 comments · May be fixed by #894
Labels
C-bug Something isn't working

Comments

@littleblack111
Copy link

Erroneous Behavior

bun upgrade not working

Expected Behavior

bun upgraded

Steps to reproduce

install bun-bin from the aur then use topgrade 2 update

Possible Cause (Optional)

no sudo access

Problem persists without calling from topgrade

  • [-] Yes
  • No

Did you run topgrade through Remote Execution

  • Yes
  • [-] No

If yes, does the issue still occur when you run topgrade directlly in your
remote host

  • Yes
  • No

Configuration file (Optional)

YES WE NEED 2 ADD A use_sudo like npm

Additional Details

  • Operation System/Version

Arch Rolling release

  • Installation

AUR

  • Topgrade version (topgrade -V)
    Topgrade 14.0.1

Verbose Output (topgrade -v)

doesnt matter


@littleblack111 littleblack111 added the C-bug Something isn't working label Aug 26, 2024
@littleblack111
Copy link
Author

dude wat?! dont download it guys. kinda sketchy

@SteveLauC
Copy link
Member

is that comment a spam comment🤔

@SteveLauC
Copy link
Member

bun update is the official command to update it, will you get an error if you simply do it in the terminal:

$ bun upgrade

@littleblack111
Copy link
Author

ye and if its installed on /usr/bin then that would need SU to update

@SteveLauC
Copy link
Member

I think Topgrade should only invoke the bun upgrade command if bun is installed through the official script, from the script (install.sh), on UNIX, bun will be installed under $BUN_INSTALL, which defaults to ~/.bun.

install_env=BUN_INSTALL
bin_env=\$$install_env/bin

install_dir=${!install_env:-$HOME/.bun}
bin_dir=$install_dir/bin
exe=$bin_dir/bun

And it looks the Windows script (install.ps1) also follows this convention:

  $BunRoot = if ($env:BUN_INSTALL) { $env:BUN_INSTALL } else { "${Home}\.bun" }
  $BunBin = mkdir -Force "${BunRoot}\bin"

Let me give this a fix.

@littleblack111
Copy link
Author

littleblack111 commented Aug 26, 2024

Pretty fair. But if it just add the use_sudo option. both will work. just user that got it installed on /usr/bin need to edit the configuration.

@SteveLauC
Copy link
Member

SteveLauC commented Aug 26, 2024

But if it just add the use_sudo option.

We should avoid this if possible as unexpected conflicts may happen.

Screenshot 2024-08-26 at 11 07 48 PM

#894 should fix this issue.

@SteveLauC
Copy link
Member

SteveLauC commented Aug 26, 2024

Here is a build for Linux, welcome to give it a test.

https://github.com/SteveLauC/topgrade/releases/tag/pr894

@SteveLauC
Copy link
Member

Here is a build for Linux, welcome to give it a test.

https://github.com/SteveLauC/topgrade/releases/tag/pr894

Gentle ping again.

@dotfrag
Copy link

dotfrag commented Aug 29, 2024

Please do not do this, bun should only be upgraded from the method used to install, i.e. package manager if AUR.

Thanks for the PR, I'm not OP but I'll try to give this a go today.

@dotfrag
Copy link

dotfrag commented Aug 29, 2024

Hi again, I'm currently on a machine with bun with official install script, and it's not working. I don't know rust but looking at the code it seems to check for ~/.bun? This might be tricky, as I've changed the install dir to ~/.local/share/bun.

@SteveLauC
Copy link
Member

the code it seems to check for ~/.bun?

That is the default installation path, one can customize it via the environment variable BUN_INSTALL.

I've changed the install dir to ~/.local/share/bun.

Did you do it through that env var?

@SteveLauC
Copy link
Member

BTW, mind giving me the output of:

$ topgrade --only bun --verbose

@dotfrag
Copy link

dotfrag commented Aug 29, 2024

I did use the var, but only passed it to bash during installation. I've now exported the var in my shell profile and it's working!

I can only test the aur install when I'm on my arch machine later today, but judging from the behavior, it should work as expected, i.e. not try to upgrade.

Thanks Steve.

Update: for the output you asked, sorry no, because I'm on a business machine with restricted access. I'm typing from my phone.

I do however see:

Step bun
Detected home.local.share.bun.bin.bun

Executing command ..bun upgrade

If I unset the var, it says Bun not installed through the official script, skipping..

Sorry for the formatting.

@SteveLauC
Copy link
Member

but only passed it to bash during installation.

Wait, bun update can still work normally without that environment variable? Ah, this makes things hard, I have no idea how I can check if an installation is done through the official script in this case...

Update: for the output you asked, sorry no, because I'm on a business machine with restricted access. I'm typing from my phone.

Thanks for the manually typed output, it still helps a lot!

@dotfrag
Copy link

dotfrag commented Aug 29, 2024

Yes it does, because, and this is only my assumption, it doesn't care about the env var, it knows where it's located from the binary itself. Even if you were to move it to /tmp and run it from there it would still work.

Maybe you could check install dir, i.e /usr/* vs ~/* but of course this is unreliable, as a user might have chosen to manually install to something like .usr.local.bin

@SteveLauC
Copy link
Member

it doesn't care about the env var, it knows where it's located from the binary itself.

Yeah, that is also my guess.

Maybe you could check install dir, i.e /usr/* vs ~/* but of course this is unreliable, as a user might have chosen to manually install to something like .usr.local.bin

Perhaps I should file an issue in the Bun repo to seek some help.

@SteveLauC
Copy link
Member

Perhaps I should file an issue in the Bun repo to seek some help.

filed: oven-sh/bun#13605

@dotfrag
Copy link

dotfrag commented Aug 31, 2024

Thanks. FWIW, I tested it on my arch system and it's working.

bun: SKIPPED: Bun is not installed through the official script, skip the update

@SteveLauC
Copy link
Member

I tested it on my arch system and it's working.

Thanks for testing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@dotfrag @SteveLauC @littleblack111 and others