Read more

ASDF: A Version Manager To Rule Them All

Julian
May 31, 2023Software engineer at makandra GmbH

tl;dr

asdf allows you to manage multiple runtime versions with a single CLI tool and is backwards compatible by supporting existing config files, like e.g. .nvmrc or .ruby-version.

Getting Started

  1. Disable rbenv
    1.1 Delete or comment out source /home/$user/.rbenvrc in ~/.profile
    1.2 Delete or comment our eval "$(rbenv init -)" in ~/.bashrcor~/.zshrc`
    1.3 To take effect you may have to restart your shell or log out and log in again from your current linux session
  2. Install asdf by following the official guide Show archive.org snapshot
  3. Install the ruby plugin by following the official guide Show archive.org snapshot
  4. Install the node plugin by following the official guide Show archive.org snapshot

Depending on how you installed rbenv, the way of disabling rbenv will vary.

Further Configurations

To add support of version files of other version managers, add the following configuration option to ~/.asdfrc:

legacy_version_file: yes
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

For a smooth experience with RubyMine you need to configure asdf in your project settings:

  1. File
  2. Settings...
  3. Languages & Frameworks
    3.1 Ruby SDK and Gems: select your ruby version
    3.2 Node.js: select your node version

ASDF vs. RBENV

RBENV ASDF Description
rbenv local asdf current ruby Show the local application-specific Ruby version
rbenv local <version> asdf local ruby <version> Set the local application-specific Ruby version
rbenv global asdf current ruby Show the global Ruby version
rbenv global <version> asdf global ruby <version> Set the global Ruby version
rbenv shell asdf current ruby Show the shell-specific Ruby version
rbenv shell <version> asdf shell ruby <version> Set the shell-specific Ruby version
rbenv install <version> asdf install ruby <version> Install a Ruby version using ruby-build
rbenv install -l asdf list all ruby List all installable ruby versions
rbenv uninstall asdf uninstall ruby <version> Uninstall a specific Ruby version
rbenv rehash asdf reshim ruby Rehash rbenv shims
rbenv version asdf current ruby Show the current Ruby version and its origin
rbenv versions asdf list ruby List installed Ruby versions
rbenv which ruby asdf where ruby Display the full path to an executable

Advantages

Life Improvements

Alias

Add the asdf-alias Show archive.org snapshot plugin to asdf to get support for managing aliases for your installed versions of ruby, node, etc. Aliases are a neat way of avoiding to install minor versions of your asdf managed tools.

Hooks

To automatically set alias every time you install a new version of a tool, add the following line to your ~/.asdfrc:

post_asdf_install_ruby = asdf alias ruby --auto

Further Improvements

Julian
May 31, 2023Software engineer at makandra GmbH
Posted by Julian to makandra dev (2023-05-31 20:45)