usernm
usernm

Reputation: 57

Need help switching from RVM to RBENV

Alright so I imploded RVM and switched to rbenv but now I think I'm having all kinds of problems with the gem path. I think some part of my system still thinks gems are supposed to be found with RVM and it's messing everything up. I'm terrible at fixing config issues like this so your help is greatly appreciated.

This is my $PATH:

/Users/home/.rbenv/shims:/Users/home/.rbenv/bin:/Users/home/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/home/.rvm/bin

So as you can see .rvm is still in the $PATH, is this my problem? How do I fix it?

Here is my gem env(This was what I got before I manually moved some directories to better match the path, now I get the same error(below) as when I run ruby or bundle):

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-darwin15.0]
  - INSTALLATION DIRECTORY: /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /Users/home/.rbenv/versions/2.1.2/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/home/.rbenv/versions/2.1.2/bin
  - SPEC CACHE DIRECTORY: /Users/home/.gem/ruby/2.1.0
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /Users/home/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
     - /Users/home/.rbenv/versions/2.1.2/bin
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/home/.rbenv/versions/2.1.2/bin
     - /usr/local/Cellar/rbenv/0.4.0/libexec
     - /Users/home/.rbenv/shims
     - /Users/home/.rbenv/bin
     - /Users/home/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Users/home/.rvm/bin

My current version of ruby is 2.1.2 and it is looking into 2.1.0 still.

Here is my .bash_profile

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

Here is my .profile

eval "$(rbenv init -)"

When I run the ruby or bundle command I get this error:

<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
    from <internal:gem_prelude>:1:in `<compiled>'

I did some tinkering with the path and manually relocated the gem directories, and I think I've done more harm than good. Thanks for the help. If you don't know the answer could someone please comment the best way to completely scrub ruby and the gem path settings so I can get a fresh reinstall? Do I just uninstall rbenv?

Upvotes: 3

Views: 615

Answers (2)

joelparkerhenderson
joelparkerhenderson

Reputation: 35483

My RVM implode script is here -- you can edit is as you like.

https://github.com/sixarm/rvm-implode-systemwide-danger

The script does RVM implode, systemwide, and is dangerous. The script will seek and destroy RVM installations, rvm gems, .rvmrc files, and then search your entire system for lingering files and and references.

Suggestions and pull requests are very welcome. I'm the author.

The entire script is copy/paste below for reference. The link above is probably better because it will have any updates, changes, improvements, etc.

#!/bin/sh
#
# Uninstall RVM (Ruby Version Manager) systemwide:
# THIS IS DANGEROUS.
#
# This script tries to eliminate RVM everywhere on the system,
# by doing these steps:
#
#   * Run `rvm implode`
#   * Delete all known RVM-related files everywhere on the system.
#   * Delete all users' home directory `.rvm` directories and `.rvmrc` files.
#   * Uninstall all known RVM gems.
#   * Search the system for potential lingering items and print them.
#
# ## Use at your own risk
#
# This script is not advanced:
#
#   * it does not do any error checking
#   * it does not ensure anything worked
#   * it does not guarantee success
#
# If it doesn't work for you, please let us know and we'll improve it.
#
# We welcome feedback, patches, and pull requests.
#
# ## Warnings
#
# Some of the script lines may report missing directories.
#
# For example, a Mac system typically has a /Users/ directory,
# whereas a Linux system typically has a /home/ directory.
# You can delete the lines that you don't need, if you like.
#
# If rvm implode gives errors like this loop:
#
#    line 72: /usr/local/rvm/scripts/rvm: No such file or directory
#
# then the rvm setup is bonked and we can delete the rvm script
# by hand then run this script again; rvm implode won't work,
# but the rest of the script will do a decent job of deleting
# any lingering rvm files and reporting any remainders.
#
# Command: rvm-implode-systemwide-danger
# Version: 2.0.0
# Created: 2011-08-22
# Updated: 2015-01-25
# License: GPL
# Contact: Joel Parker Henderson ([email protected])
##
set -euf
out () { printf %s\\n "$*" ; }

out "rvm implode"
rvm implode

out "remove rvm files from system-wide areas"
sudo rm -rf /usr/local/bin/rvm
sudo rm -rf /usr/local/rvm
sudo rm -rf /etc/rvmrc
sudo rm -rf /etc/profile.d/rvm.sh

out "remove rvm files from all likely user areas"
sudo rm -rf /home/*/.rvm
sudo rm -rf /home/*/.rvmrc
sudo rm -rf /Users/*/.rvm
sudo rm -rf /Users/*/.rvmrc
sudo rm -rf $HOME/.rvm
sudo rm -rf $HOME/.rvmrc
sudo rm -rf $(dirname $HOME)/*/.rvm
sudo rm -rf $(dirname $HOME)/*/.rvmrc

out "uninstall rvm gem as current user and with sudo"
gem uninstall -a -q rvm
sudo gem uninstall -a -q rvm

out "delete rvm group"
sudo /usr/sbin/groupdel rvm

out "try to find any remaining .rvmrc files, in case you want to delete them"
sudo find -L / -name .rvmrc

out "try to find rvm text in configuration files, in case you want to edit thme"
sudo find -L / -type f | grep "\(bash_login\|bash_profile\|bashrc\|profile\|zshenv\|zshrc\|zlogin\|zlogout\|zprofile\)$" | xargs -I{} grep -Iil "rvm" {}

Upvotes: 2

vgoff
vgoff

Reputation: 11323

Ensure that you are checking all of your "rc" files. This includes ~/.bashrc and ~/bash_login, if they exist.

Using a tool like grep can help you find them.

grep 'rvm' -l ./.* maybe, to get the filenames that any reference to rvm may be in.

Upvotes: 2

Related Questions