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
- Disable rbenv
1.1 Delete or comment outsource /home/$user/.rbenvrc
in~/.profile
1.2 Delete or comment oureval "$(rbenv init -)"
in~/.bashrc
or~/.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 - Install asdf by following the official guide Show archive.org snapshot
- Install the ruby plugin by following the official guide Show archive.org snapshot
- 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
For a smooth experience with RubyMine you need to configure asdf in your project settings:
- File
- Settings...
- 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
- Manage multiple runtime version with a single CLI tool
- Large ecosystem of plugins Show archive.org snapshot
- Backwards compatible (
.ruby-version
, etc.) - Easily create Show archive.org snapshot a new plugin
- One config file
.tools-version
- Shell support
- GitHub Actions
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
Posted by Julian to makandra dev (2023-05-31 18:45)