Deprecation of rbenv on Bitrise: Switching to asdf

Photo by James Harrison / Unsplash

Bitrise, the Continuous Integration and Delivery (CI/CD) Platform, has recently deprecated the use of rbenv. This means that rbenv will no longer receive updates and support. But don't worry, there's a new tool in town - asdf! This blog post will guide you through the process of switching from rbenv to asdf.

If you need more reasons to change tool, asdf has many features:

  1. Multiple Language Support: asdf is not limited to Ruby. It supports a wide range of programming languages and tools including Node.js, Python, Elixir, Erlang, and many more. This means you can manage versions of all these languages using a single tool.
  2. Plugin System: asdf uses a plugin system, which means you can extend its functionality to support more languages or tools. There are already many community-contributed plugins available.
  3. Per-project Version Settings: Like rbenv, asdf allows you to set the version of a language/tool on a per-project basis. This is done by placing a .tool-versions file in your project directory.
  4. Ease of Use: asdf provides a simple, consistent interface for managing versions of different languages/tools. Once you learn how to use asdf, you can apply the same knowledge to manage versions of all supported languages/tools.
  5. Compatibility: asdf is compatible with both Unix and Unix-like systems including macOS, and it also works well with the Windows Subsystem for Linux (WSL).
  6. Global and Local Version Management: asdf allows you to set global versions for your languages/tools, but also override them on a per-project basis. This gives you a lot of flexibility in managing versions.

Uninstalling Ruby Versions and rbenv on Mac using Brew

Before uninstalling rbenv, it's important to uninstall any existing versions of Ruby that were installed through rbenv. You can do this by running the following script in your terminal:

versions=$(rbenv versions --skip-aliases --bare)
for version in $versions; do
  echo "Removing Ruby version $version"
  rbenv uninstall $version

The script gets all installed versions, iterates over them, and uninstalls. Clean and easy!

Once you've uninstalled all versions of Ruby, you can uninstall rbenv. If you installed rbenv using Homebrew, you can uninstall it by running the following command in your terminal:

brew uninstall rbenv

This command will remove rbenv and its dependencies from your system.

Cleaning Up zshrc

After uninstalling rbenv, it's a good idea to clean up your shell configuration file (~/.zshrc for Zsh users) by removing any rbenv related lines. This step is important to prevent any potential conflicts with asdf.Open your ~/.zshrc file in a text editor and look for lines that mention rbenv. These lines might look something like this:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Remove these lines, then save and close the file. Afterward, source your ~/.zshrc file to apply the changes by running:

source ~/.zshrc 

Installing and Setting Up asdf

Now, let's install asdf. You can do this by running the following commands in your terminal:

brew install asdf

After installing asdf, you need to add it to your shell so that it can be used from the command line. Add the following lines to your ~/.zshrc file:

. "/usr/local/opt/asdf/libexec/"
. "/usr/local/opt/asdf/etc/bash_completion.d/asdf.bash"

Then, source your ~/.zshrc file to apply the changes:

source ~/.zshrc 

Installing Ruby with asdf

With asdf installed and set up, you can now install Ruby. To install Ruby 3.1.4, run the following command:

asdf install ruby 3.1.4

Using Local and Global Environments

asdf allows you to manage both local and global environments.

To set a global version for a tool, use the asdf global command followed by the tool name and the version number. For example, to set Ruby 3.1.4 as the global version, you would run:

asdf global ruby 3.1.4

To set a local version for a tool, use the asdf local command followed by the tool name and the version number. This will create a .tool-versions file in your current directory, which asdf will use to determine the version to use. For example, to set Ruby 3.1.4 as the local version, you would run:

asdf local ruby 3.1.4 

And that's it! You've successfully switched from rbenv to asdf on Bitrise. Happy coding!

Artur Gruchała

Artur Gruchała

I started learning iOS development when Swift was introduced. Since then I've tried Xamarin, Flutter, and React Native. Nothing is better than native code:)