Skip to content

Followup latest version of the tools using asdf

Posted on:October 10, 2022 at 01:07 PM

A Comic By by Monkey User about a Final patch in production

Disclaimer!: This post only talks about asdf .
afx is also quite new to me too and I don’t have enough experience to help you out, maybe you can let me know or point me in the correct direction if you find something and I will update it here.

Table of contents

Open Table of contents

Why this post

If I don’t care about the version of a tool just that I have the latest, what should I do? — rephrased ;)

Aashish

asdf install latest

Install latest stable version that begins with a given string.

asdf install latest:

However, I have not used it myself recently and earlier it did not work.

What do I use? a self developed shell script. (it probably does not work directly on mac) : update-asdf.sh.

Let’s see it in action shall we?

This is what I use, and I know it’s a little rough around the edges but get’s the job done. What does it do?

  1. Reads the .tool-versions and and adds all the plugins for each listed tool. YMMV
  2. Updates all the Plugins (they are each their own git repo)
  3. Runs asdf install
  4. Asks if you want make all versions global. (just creates / appends / updates ${HOME}/.tool-versions)
  5. Checks each plugin for a newer version and show top three versions.
    • Some personal optimizations are applied, like for java only use temurin
    • Ignore some alpha / beta / pre-dev / dev / some error versions seens
  6. Then for each update show one line in place edit sed command to update individual tool
  7. Also, a consolidated sed to update all tools at once
  8. there is a update-asdf.sh -n flag that runs in non-interactively by saying yes but does not actually update any versions.

alternative option

There’s also an interesting use of the excellent fzf to update asdf tool versions

# Install one or more versions of specified language
# e.g. `vmi rust` # => fzf multimode, tab to mark, enter to install
# if no plugin is supplied (e.g. `vmi<CR>`), fzf will list them for you
# Mnemonic [V]ersion [M]anager [I]nstall
vmi() {
  local lang=${1}

  if [[ ! $lang ]]; then
    lang=$(asdf plugin-list | fzf)
  fi

  if [[ $lang ]]; then
    local versions=$(asdf list-all $lang | fzf --tac --no-sort --multi)
    if [[ $versions ]]; then
      for version in $(echo $versions);
      do; asdf install $lang $version; done;
    fi
  fi
}

In action

This too does not update the versions in the .tool-versions file, but probably is not too hard to add that in. This exercise is left for the reader (I’ve always wanted to say that)

A monkeyuser comic on backlogs

Extro

Pick one from above, maybe modify it to update the tool to the latest and then run asdf install schedule the run of the chosen method non-interactively and that should take you further until something breaks because of an update.

So that’s it, hope this helps!