Skip to content

self update mechanism for 0.16+ #1913

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

Closed
jeffguorg opened this issue Feb 7, 2025 · 5 comments
Closed

self update mechanism for 0.16+ #1913

jeffguorg opened this issue Feb 7, 2025 · 5 comments

Comments

@jeffguorg
Copy link

Is your feature request related to a problem? Please describe

hi. i was using asdf for a few years. it's fantastic when i need to setup and sync development environment across a few boxes. i can update plugins, installations, default packages, and of course i can asdf update to update asdf itself.

but since 0.16 asdf has no self update mechanism, i can no longer update itself.

on some system asdf is packaged and thus i can install it with package manager. it's good. but what about other systems?

Describe the proposed solution

i just want asdf update or similar things to manage itself

Describe similar asdf features and why they are not sufficient

asdf update is the closest thing, but it is removed

Describe other workarounds you've considered

i...

  • tried to create a plugin to manage asdf, but found asdf will exec itself again and again forever
  • tried to use golang plugin to install it, but found asdf will exec itself forever

i'm thinking about something like https://github.com/fynelabs/selfupdate or https://github.com/minio/selfupdate

@Stratus3D
Copy link
Member

Hi @jeffguorg , using your OS-package manager, go install, or binary download is the recommended way to update asdf. Currently the latest version asdf is available via Brew and AUR, but we are hoping more package managers add asdf as a package soon. Since it is now just a binary that can be generated with go build it is now very easy for package registries to create asdf packages. Closing as this is not a feature we want to dedicate time to now.

@jeffguorg
Copy link
Author

@Stratus3D get it. still thanks to you and community for your great work!

Currently the latest version asdf is available via Brew and AUR, but we are hoping more package managers add asdf as a package soon. Since it is now just a binary that can be generated with go build it is now very easy for package registries to create asdf packages. Closing as this is not a feature we want to dedicate time to now.

sure! it is exciting to have it in system package manager. but

  • sometimes the packagers freeze the version in a regular distro release like ubuntu/debian, rpm-distros, alpine, ... so on. not everyone is using rolling release linux like Archlinux.
  • In some environment people don't have access to third party repos or system package manager.
  • It is annoying to update binaries when it is managed manually.

So people like me still want a way to use the latest version, while it is still managed somehow, by itself or by system package manager, instead of just been put in the PATH and updated by hand. and we don't want to deal with PPAs or COPR, which increases the complexity of system management. in such cases, the need of self update is still sensible.

i understand it is a choice already made and i believe it is a good choice, just searching for a method that make it work better.

@Stratus3D
Copy link
Member

There are definitely downsides to our approach. We may re-visit this in the future.

@mhagnumdw
Copy link

A dedicated command would be great. Or we could have a plugin to manage the versions of asdf itself:

asdf plugin add asdf
asdf install asdf latest
asdf global asdf latest

@jeffguorg
Copy link
Author

jeffguorg commented Mar 2, 2025

@mhagnumdw

it will not work for now. I have tried that. you don't even need an new asdf plugin. just use golang plugin and write github.com/asdf-vm/asdf/cmd/asdf@latest to $HOME/.default-golang-pkgs and you get a shim to latest version of asdf at the time you install new version of golang

currently golang plugin is broken due to missing GOBIN environment variable when install golang package binaries. it will work after asdf-community/asdf-golang#152 is merged. or you can apply patch to plugin as suggested in asdf-community/asdf-golang#151

how asdf works:

  1. asdf adds shim scripts to shims directory.
  2. when you run a command of asdf installations, you actually run the shim script.
  3. the script then run asdf command like asdf exec <shim-name> args to let asdf binary find the actual version and run the binary.

why plugin managed asdf does not work

if you put an shim to asdf to shims directory, it will loop between step 2 - 3

  • step2: you run asdf blablabla, actually you are running ~/.asdf/shims/asdf blablabla
  • step3: shim resolve to exec asdf exec asdf blablabla
  • the asdf command is actually shim to asdf, so it comes back to step 2
  • step2: shim run asdf exec asdf blablabla
  • step3: shim resolve to exec asdf exec asdf exec asdf blablablabla
  • whoooops

a possible solution, a patch to asdf, could be that: when asdf update the shims, it tries to resolve the absolute path to it self by os.Executable and use it in shims whenever possible. but here is the problem: you need to reshim EVERY TIME YOU UPDATE ASDF and it can break easily. i think it can work theoretically but will not work in reality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants