goterpsgo
goterpsgo

Reputation: 317

How to get asdf and rvm to co-exist

Is it possible to have asdf and rvm coexist? If so, how do you set it up? I made a test project to try out asdf but it seems that's affecting another existing project that's managed by rvm. When I run rails I'm getting:

asdf: No version set for command ruby
you might want to add one of the following in your .tool-versions file:

ruby 2.6.1

Upvotes: 2

Views: 1778

Answers (2)

Stephen Baidu
Stephen Baidu

Reputation: 41

This is the hack I currently use. Running use-rvm or use-asdf uncomments the respective line in my ~/.bash_profile, and comments the unwanted line.

# RVM
# source $HOME/.rvm/scripts/rvm

# ASDF
. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash

# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

use-rvm () {
  sed -i "" 's|^# source $HOME/.rvm/scripts/rvm|source $HOME/.rvm/scripts/rvm|' ~/.bash_profile
  sed -i "" 's|^. $HOME/.asdf/asdf.sh|# . $HOME/.asdf/asdf.sh|' ~/.bash_profile
  bash --login
}

use-asdf () {
  sed -i "" 's|^source $HOME/.rvm/scripts/rvm|# source $HOME/.rvm/scripts/rvm|' ~/.bash_profile
  sed -i "" 's|^# . $HOME/.asdf/asdf.sh|. $HOME/.asdf/asdf.sh|' ~/.bash_profile
  bash --login
}

And here's the gist

Upvotes: 1

Malik
Malik

Reputation: 3680

I've came across the same issue while installing asdf in macOS. I was able resolve it by creating .tool-versions file and adding the ruby version entry. You can do the same by running following command in the terminal.

$ echo 'ruby 2.6.1' >> .tool-versions

more information can be found here in this blog post

Upvotes: 0

Related Questions