Remove RVM, Ruby and gems completely? - ruby-on-rails

I had to downgrade Rails and now the gems, the versions, and everything, are completely messed up and I feel like jumping from my window.
I just want to destroy everything related with RVM, Ruby and gems to make sure I make a 100% clean reinstallation.
How can I do that?

Linux and installed as regular user ? Than all you need to do is:
rm -Rf ./.rvm
rm -Rf ./.gem
rm -f ./.gemrc
You can also check ~/.bashrc and ~/.bash_profile files for lines like this:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
This should be enough. If you've installed it in some custom way then try this:
$ rvm list # to see what version you have installed
$ rvm gemdir # to see where are gemfiles located
There is something like rvm remove as well but, if you want to just remove all, than it's not very interesting I think.

If you have installed everything via rvm a simple
rvm implode
will remove all traces of rvm including rubies and gems. Even (as far as I remember, I'm not testing it right now) the shell files are updated.

rvm implode which removes all ruby installations rvm manages, everything in ~/.rvm

Related

How to remove complete RVM from system with .bashrc and .bash_profile

I have some issue with my current RVM. I am not able to upgrade it and also not able to install new ruby version. I am also not able to install new gems in my system as on bundle install it returns rubygems error(getaddrinfo-error).
Please suggest me right direction to remove it and reinstall it safely.
Thanks
rvm implode
From the rvm 'documentation':
(seppuku) removes the rvm installation completely.
This means everything in $rvm_path (~/.rvm || /usr/local/rvm).
This does not touch your profiles. However, this means that you must
manually clean up your profiles and remove the lines which source RVM.
So I'd say you execute rvm implode and then remove every rvm related line you inserted in .bash_profile, .profile, .bashrc etc.
Type these commands:
cd ~
rm -rf .rvm
Those will move you to your home directory, and remove the current ~/.rvm directory.
At that point, you can reinstall RVM without needing to remove the initializers from your .bashrc or .bash_profile files.
It's important to understand RVM's installation process, so I strongly suggest you read through that document before you reinstall.

Made a mistake installing RVM with sudo. How to reverse?

I am new to Rails and Linux and have installed RVM with sudo.
sudo bash -s stable < <(curl -s
https://raw.github/wayneeseguin/rvm/master/binscripts/rvm-installer)
Now I have to run most commands (like spork) with 'rvmsudo'. It is redundant, and the way I learned, when something is redundand it is often wrong. How to get rid of this nuance? Is the only way to reinstall RVM? If so, how to properly reinstall?
Use rvm implode to uninstall rvm. Check that there are no environment variables left over in /etc/profile, /etc/bash_profile or whatever shell you're using. Once you do that, then re-install using the single user guide found here.
You'll have to execute the implode command using sudo since you installed it as root.
1)remove in home directory:
rm -rf .rvm*
2)remove from your bash file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
3) remove from /etc/rvmrc file
sudo rm -rf /etc/rvm*
4)Delete everything else
sudo groupdel rvm
I couldn't find a complete/concise step-by-step to 100% remove rvm when it was run as root. Here's what I came up with, and I've tested it three times successfully:
sudo su -
rvm implode
groupdel rvm
rm /etc/rvmrc
rm /etc/profile.d/rvm.sh
You'll also want to double check that you don't have ~/.rvm or ~/.rvmrc or any rvm whatnot in your .bashrc (possibly .bash_profile on OSx), as you've likely been trying to install rvm several ways by this point!
Next, you'll need to reboot, as the global environment variables set in /etc/profile.d/rvm.sh will keep getting populated in new shells until you do. After rebooting, open a terminal and try this command to test:
echo $rvm_path
If it's empty, that means you've succeeded! If not, it'll most likely be set to /usr/local/rvm.

RVM switching to #global gemset instead of a specific one

When I enter my rails dir on server RVM switch to
/home/capistrano/.rvm/gems/ruby-1.9.2-p290#global/bin/bundle
although it should use ruby-1.9.2-p290#mygemset/bin/bundle as it works on my local machine. When I type rvm use 1.9.2#mygemset it works. Nginx server is also looking for gems in the #global gemset
my .rvmrc file:
environment_id="ruby-1.9.2-p290#mygemset"
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
then
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
if ! rvm --create use "$environment_id"
then
echo "Failed to create RVM environment '${environment_id}'."
return 1
fi
fi
I'm not sure if I understood you but you could place an .rvmc file in your rails folder and put something like this in it.
rvm use ruby-1.9.2#mygemset
Whenever you cd into that directory rvm will use settings from the .rvmc file.
RVM is going through rapid develpment so the syntax and functionality of commands sometimes vary. Anyway, I solved it with upgrading to stable RVM:
rvm get stable
which is now rvm 1.14.1 (stable). Afterwards commands like rvm 1.9.3-p194#mygemset --create
works perfectly.
Another thing I was missing is the new syntax for executing commands:
rvm #mygemset do bundle install
This will install all gems for given gemset and ruby specified in .rvmrc file

Setting the RVM path?

I installed RVM, Ruby 1.9.2 and Rails 3.0.9 on Lion which works fine. Only problem is, after I close the terminal I need to execute this:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
for it to pick up RVM.I then need to make RVM use Ruby 1.9.2 first before I can do Rails stuff again.
How can I make this permanent?
After you first execute
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
you shouldn't need to do it again. That line appends the necessary file inclusion information RVM into your .bash_profile. If you are using bash (as opposed to zsh, ksh, csh, tcsh or any other shell), then RVM will be accessible each time you open a new session. If you are using a different shell, that line may need to be in a different startup file. For example, if you are using zsh, then you'll probably want to append it to your ~/.zshrc file.
Having done this, simply running rvm --default use ruby-1.9.2 once should ensure that you have the desired version of Ruby by default. Note, you should not need to add this line to your .bash_profile or similar.
try this
rvm --default use ruby-1.9.2
In order to make Terminal (e.g. bash) enable RVM every time you open it, edit ~/.profile and add the following line to it:
[[ -s "/Users/foo/.rvm/scripts/rvm" ]] && source "/Users/foo/.rvm/scripts/rvm" # This loads RVM into a shell session.
Then to make the RVM's version of ruby default, as fl00r has mentioned, run:
rvm --default use ruby-1.9.2
Alternatively, you can add an .rvmrc file to the root folder of your app that uses Rails 3.0.9 and specify which version of Ruby you want to use with that project there:
rvm ruby-1.9.2
Even better, you should create a gemset by running rvm gemset create rails-3.0.9 and update you .rvmrc file to become like this:
rvm ruby-1.9.2#rails-3.0.9
Then run cd into the project once again (you must cd into it once again), and run bundle install.
This way your project will have its own isolated gemset.
this also work for me
rvm --default use 1.9.2

Cannot install RVM . Permission denied in /usr/local/rvm

Based on my previous thread : RVM installed by Ruby not working? where i had installed RVM using the root user, I then had to entirely remove the RVM install and now i am installing as a user.
So i did :
Create a new user by doing : useradd newuser
Follow the instructions on the RVM website and execute the command : bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Now, i get the error : mkdir: cannot create directory `/usr/local/rvm': Permission denied
The new user i created does not have access to this directory. I manually tried creating the folder but the same error. Please help.
EDIT : The original problem occured because i did not restart the terminal and it was still using the old settings.
Now, I got a new problem : After installing RVM, i cannot run it and it gives me an error : rvm command not found.
Here is the output of my ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
And here is output from ~/.bashrc file
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
mkdir: cannot create directory `/usr/local/rvm': Permission denied
If you've run the rvm installer as root previously, remove /usr/local/rvm and /etc/rvmrc.
RVM is easy to install, but you are making it harder by trying to mix and match installation types. You do NOT need to create a new user. When run, RVM will create a directory in your home directory: ~/.rvm, and install everything inside it. That means you will have all the correct permissions. You do NOT need to be running as root, you do NOT need to use sudo. I'd recommend closing all your command-lines and open one fresh and start at your home directory. If you are running as root, log out, and log back in to your normal account. For a single-user install you do NOT need to be root.
For a single user, using RVM as their Ruby sandbox, use the single-user installation docs. Follow ALL the instructions on that page, INCLUDING the "Post Install" section.
Close your terminal window, and reopen it. If you have correctly followed the instructions above, typing rvm info should spit out a template of what is to come once you install a Ruby instance. If you see nothing output, or get an error, then retrace your steps in the "Post Install" section, and go through the "Troubleshooting" section. Most of the problems people have occur because they didn't bother to read the directions.
Once RVM is installed, type rvm notes and read what dependencies you need to install. If you do not add those files your Rubies installed will be missing functionality. They will work, but some of the creature comforts you'll hear about won't work and you will wonder why.
After installing the dependencies you should be in good shape to install Rubies. Type rvm list known for all the Rubies RVM can install. If you want 1.8.7 type rvm install 1.8.7, and, similarly, rvm install 1.9.2 for Ruby 1.9.2. If you want a particular revision you can add that, based on the ones in the list.
It's important to periodically update RVM using rvm get head. That will add features, fix bugs, and tell RVM about new versions of Ruby it can install if you request.
After installing a Ruby, type rvm list and it should show up in the list, looking something like this:
rvm rubies
ruby-1.8.7-p334 [ x86_64 ]
ruby-1.9.2-p180 [ x86_64 ]
Type rvm use 1.9.2 --default to set a default Ruby that will be sticky between logins. Use the version of whatever Ruby you want to default to if 1.9.2 doesn't float your boat. Once you've defined a default it should look something like:
rvm rubies
ruby-1.8.7-p334 [ x86_64 ]
=> ruby-1.9.2-p180 [ x86_64 ]
Before you begin installing gems into a RVM-managed Ruby, read "RVM and RubyGems ", in particular the part that says "DO NOT use sudo... ". I repeat. Do NOT use sudo to install any gems, in spite of what some blog or web page says. RVM's author knows better when it comes to working with RVM controlled Rubies. That is another mistake people use with RVM, again as a result of not reading the directions.
On Mac OS, you'll need the latest version of XCode for your OS. Do NOT use the XCode that came with Snow Leopard on the DVD. It is buggy. Download and install a new version from Apple's Developer site. It's a free download requiring a free registration. It's a big file, approximately 8GB, so you'll want to start it and walk away. Install XCode, and you should be ready to have RVM install Rubies.
Finally, RVM installs easily, as will the Rubies you ask it to install. I have it on about four or five different machines and VMs on Mac OS, Ubuntu and CentOS. It takes me about a minute to install it and another minute to configure it and start installing a new Ruby. It really is that easy.
I had the original issue reported in this question, "mkdir: cannot create directory `/usr/local/rvm': Permission denied" when trying to install rvm.
This is my scenario and how I solved it - maybe this will help others with this same issue.
I have Ubuntu 11.04 installed on a laptop, I only have 1 user, the one I created at install time, named nathan. When I would try to install rvm as nathan, the rvm installer saw me as root and kept trying to install rvm globally, but since I wasn't really root, it couldn't get access to create directories in /usr/local/rvm.
I'm far from an expert with Ubuntu, so I'm sure there are easier/better ways to accomplish the things I did (and I would love to learn about them), but this worked for me:
I created a new user called rubydev
I logged in as rubydev, opened a terminal and typed:
rubydev~$ bash < <(curl -B http://rvm.beginrescueend.com/install/rvm)
rvm installed correctly and I logged out of rubydev
Signed back in as nathan, opened a terminal and typed "su" (you could do all this with sudo, I am lazy)
After successfully getting root, I typed the following commands:
root: /home/nathan# cp -R /home/rubydev/.rvm .
root: /home/nathan# chown -R nathan .rvm
root: /home/nathan# chgrp -R nathan .rvm
root: /home/nathan# exit
nathan~$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
nathan~$ echo 'export rvm_path="/home/nathan/.rvm"' > ~/.rvmrc
nathan~$ source .bash_profile
At this point, rvm was correctly installed under my home directory. To verify I typed:
nathan~$ type rvm | head -1
rvm is a function (if you don't get this response, something else is wrong)
Read the notes and installed any dependencies
nathan~$ rvm notes
I installed some rubies
nathan~$ rvm install 1.8.7-head
nathan~$ rvm install 1.9.2-head
Verified install
nathan~$ rvm list
rvm rubies
ruby-1.8.7-head [x86_64]
ruby-1.9.2-head [x86_64]
nathan~$ rvm use 1.9.2
using /home/nathan/.rvm/gems/ruby-1.9.2-head
nathan~$ rvm list
rvm rubies
ruby-1.8.7-head [x86_x64]
=> ruby-1.9.2-head [x86_x64]
Finally, I edited the preferences on the terminal itself to ensure the "Run command as as login shell" under the "Title and Command" tab was checked. It seems .bash_profile isn't otherwise processed.
I removed the rubydev user I created in step 1.
With all of that, I have a working rvm under Ubuntu 11.04 using my preferred username.
I solved this by adding
export rvm_path=~/.rvm
to ~/.bash_profile
If you first installed RVM as root and then uninstalled it. And now you are trying to install it as a non sudo user and you're getting the following error:
mkdir: cannot create directory `/usr/local/rvm': Permission denied
Make sure that you have logged out of the root session before trying to install under the user.
If you installing RVM as a user then the RVM folder should be generated in your home directory:
~/.rvm
Where there should be no permissions problems at all.
I would suggest it is picking up some old config that is left over from your system installation.
Ensure there is no /etc/rvmrc or $HOME/.rvmrc file left over because it might be using previously initialised variables from these files to construct an incorrect installation path.
if we look at this section of the bash script:
if [[ ${rvm_ignore_rvmrc:-0} -eq 0 ]]; then
for file in /etc/rvmrc "$HOME/.rvmrc " ; do
if [[ -s "$file" ]] ; then
source $file
fi
done
fi
It is trying to find one of these files, if it finds one if will run it possibly initialising rvm_path which will subsequently not be set as $HOME/.rvm by this command
rvm_path="${rvm_path:-"$HOME/.rvm"}"
I had the same issue. When I tried to create a gemset I would get a permission denied error. I just forgot to run the "rvm use 1.8.7" command first. After that I was able to create and use the gemset without any problems.
In lasts versions of rvm you need remove /etc/profile.d/ also.
This happen often if you try to install as root and then try again as a regular user.
Hope this help.
Look for file rvm.sh below /etc directory (It may be in /etc, or /etc/init.d).
Also, try some grep rvm /etc -r, so you can find some files/lines which prevent you from installing rvm in your $HOME dir.
For me running
__rvm_unload
Worked first, this was due to the fact that I had rvm installed as for multiuser.
If you installed rvm as root and you are getting permission denied issues (maybe you are deploying with capistrano as a non root user) then you could try rvm fix-permissions after doing things like rvm install 2.2.2 as root and creating a gemset as root.
Scott Bartell's solution worked for me. i am on a Digital Ocean premade image, where they had already setup rvm as root.
1. deleted /etc/rvmrc .
2. added export rvm_path=~/.rvm to ~/.bash_profile
3. logged out of ssh session to virtual machine
4. logged back in and presto!
would have commented but rep is 3 points too low :)

Resources