In order to install Ruby and Rails on Ubuntu 18.04, first I had to completely wipe my first, abortive attempt. That proved to be harder than expected. So, in order to save others the effort I had to go through, here’s what I did. This worked for me…who knows if it’ll work for you, though? I compiled some of the rm -f commands from other sources, but others I figured out myself. If it works, this should completely wipe Ruby and Rails (and other associated command line things, including rvm but not rbenv) from your system, so you can start over with a clean slate. Don’t complain to me if anything goes wrong, but if you want to suggest helpful edits, please do. Some of these commands require sudo; if you save this as a .sh file, though (as I did), you can sudo the whole thing.
# HOW TO DELETE RUBY AND RAILS (AND OTHER GEMS)
apt-get purge ruby2.5
aptitude purge ruby
rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem
rm -rf /home/globewalldesk/.gem/ruby
rm -rf /home/globewalldesk/.codeintel/db/ruby
rm -rf /usr/local/bin/rails
rm -rf /var/lib/gems/
rm -rf /home/globewalldesk/.bundle/
rvm implode
rm -rf ~/.rvm
unset rvm_path
# THEN DO THIS TO MAKE SURE YOU'RE CLEAN:
# sudo find / -name 'rvm' -name 'rbenv' -name 'ruby' -name 'rails' -name 'gem'
# sudo find / -name 'rbenv'
# sudo find / -name 'ruby'
# sudo find / -name 'rails'
# sudo find / -name 'gem'
# sudo find / -name 'railties'
# cat ~/.bash_profile ~/.bashrc ~/.profile ~/.zshrc ~/.mkshrc ~/.zlogin | grep 'rvm\|rbenv\|ruby\|rails\|gem\|railties' # search for keywords in your bash profiles--they might need to be deleted
# env | grep rvm_path # ensure it's unset
Leave a Reply