Disable Rvm or Use Ruby Which Was Installed Without Rvm

Disable RVM or use Ruby which was installed without RVM?

Try rvm use system to use the system ruby which is not managed via. rvm.

How to remove RVM (Ruby Version Manager) from my system

There's a simple command built-in that will pull it:

rvm implode

This will remove the rvm/ directory and all the rubies built within it. In order to remove the final trace of rvm, you need to remove the rvm gem, too, if you installed that:

gem uninstall rvm

There may be elements left over from a Homebrew, Apt or DNF install of it that require removal as well. This depends on how you installed it in the first place. That clean-up step is optional, as RVM will no longer be involved in Ruby, but can help keep things organized.

If you've made modifications to your PATH you might want to pull those, too. Check your .bashrc, .profile and .bash_profile files, among other things.

You may also have an /etc/rvmrc file, or one in your home directory ~/.rvmrc that may need to be removed as well.

Using RVM with Ruby already installed

It is possible to get RVM to manage multiple Ruby versions but you have to give it some help, and it can't do it with Rubies it didn't compile and install.

Any Rubies RVM didn't install are considered "system", even though there might be multiple ones. Using rvm system tells RVM to remove its path information from the front of your PATH environment variable, letting the shell do its normal search, which hopefully lands on a ruby binary. If you have multiple Rubies outside of RVM's control, you'll have to manually adjust your path. That's the cost of doing it outside of RVM.

If you want to have RVM install and manage Rubies you can manually copy the Ruby distribution source tarball files into ~/.rvm/archives. Here's the file's you'll need for the current 1.8.7 and 1.9.2:

ruby-1.8.7-p330.tar.bz2
ruby-1.9.2-p136.tar.bz2
rubygems-1.3.7.tgz

Once they're installed in that folder you should be able to tell RVM to rvm install 1.9.2-p136 or rvm install 1.8.7-p330 and it will extract the contents to ~/.rvm/src and begin the configure, compile, install steps. If it whines at all it will probably want you to unarchive those files into ~/.rvm/src first. Then try the install commands again. Basically we're playing with RVM's mind at this point, so if you run into problems you should probably ask the developer for help. You can get his email via rvm -v.

That's what I have to do with one of my hosts and it works.

Use RVM Ruby instead of MAMP Ruby

As Dave Newton suggested, this smells like a PATH issue, but in the case of MAMP, it's also an alias issue.

If you open ~/.profile and ~/.zprofile, in one of them you will probably see these lines:

alias erb='/Applications/MAMP/Library/bin/erb'
alias gem='/Applications/MAMP/Library/bin/gem'
alias irb='/Applications/MAMP/Library/bin/irb'
alias rake='/Applications/MAMP/Library/bin/rake'
alias rdoc='/Applications/MAMP/Library/bin/rdoc'
alias ri='/Applications/MAMP/Library/bin/ri'
alias ruby='/Applications/MAMP/Library/bin/ruby'
alias rails='/Applications/MAMP/Library/bin/rails'

You'll want to remove them all, save the file, then quit and restart iTerm2.

If you don't know how to open and edit dotfiles, read my guide that explains various ways to read and edit dotfiles on a Mac.

If removing those aliases doesn't fix it, then it's a PATH issue.

For your Mac to know about a command or other executable program, it has to be told where to look for it. It wouldn't be efficient for the computer to search the entire hard drive for the program.

Instead, it looks in a specific list of locations, which are stored in an environment variable called PATH, separated by a colon. You can view this list by running this command in your terminal:

echo $PATH

When you install new programs, such as Ruby, they might get installed in a location that is not already included in the PATH. If you don't add this new location to the PATH, the computer won't know to look for it there, and so it thinks it doesn't exist.

Similarly, if the location of the new program did get added to the PATH, but you have another location for the same program earlier in the PATH, then it will always use the first one it finds.

Most Ruby version managers use a script to automatically update the PATH, and they instruct you to add a line to your shell file to call that script, or they might add it for you. That line should come after any modifications of PATH.

It's been a while since I've used RVM (I no longer recommend it), but I think it's supposed to automatically add this line to your shell file:

source $HOME/.rvm/scripts/rvm

Assuming you installed RVM properly, here's what I would try:

  1. Open your shell file. It should be ~/.zshrc if you're using oh-my-zsh.

  2. Look for any lines that start with export PATH=, and if they mention /Applications/MAMP/Library/bin/ruby, remove that directory from the PATH. Also make sure any PATH lines come before the lines added by RVM.

  3. Quit and restart iTerm2

If you don't see any RVM-related lines in ~/.zshrc or ~/.zprofile or ~/.profile, then RVM was not properly installed.

If you really want to use RVM, try uninstalling and reinstalling it. If all you care about is having a working Ruby environment, I would recommend chruby and ruby-install. You can install them by following my step-by-step guide to install Ruby on Mac.



Related Topics



Leave a reply



Submit