Made a mistake installing RVM with sudo. How to reverse? - ruby-on-rails

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.

Related

Remove RVM, Ruby and gems completely?

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

PATH .bash_profile, Home Brew, rvm, and one line I can't shake upon opening up a shell

OSX - 10.8.5
Running Homebrew
rvm
Whenever I open a new shell I get the following and I think, "ugh", thats not good.
Last login: Thu Nov 7 07:12:43 on ttys000
-bash: /etc/profile.d/rvm.sh: No such file or directory
I then run echo $PATH and get
Matthews-MacBook-Pro-2:~ Matthew$ echo $PATH
/Users/Matthew/.rvm/gems/ruby-1.9.3-p448/bin:/Users/Matthew/.rvm/gems/ruby-1.9.3-p448#global/bin:/Users/Matthew/.rvm/rubies/ruby-1.9.3-p448/bin:/Users/Matthew/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/opt/ImageMagick/bin:/usr/local/bin:/Applications/Postgres.app/Contents/MacOS/bin:/usr/local/rvm/gems/ruby-1.9.3-p448/bin:/usr/local/rvm/gems/ruby-1.9.3-p448#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p448/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Matthews-MacBook-Pro-2:~ Matthew$
I think my .bash_profile is a mess and I really would appreciate some ninja guidance...
Thank you
When you open the Terminal, you begin a bash shell session. You can set some commands to run every time you start a bash session. The place to put these initial bash commands is usually in ~/.bashrc or ~/.bash_profile. See if you have any reference to the file /etc/profile.d/rvm.shthere and check if that file actually exists on your machine.
UPDATE:
I have heard of problems if o installed rvm as sudo. Try removing it and reinstalling again without sudo:
sudo rm -rf $HOME/.rvm $HOME/.rvmrc /etc/rvmrc /etc/profile.d/rvm.sh \
/usr/local/rvm /usr/local/bin/rvm
sudo /usr/sbin/groupdel rvm # this might fail, it's not that important
Reopen terminal and make sure rvm ins removed:
env | grep rvm
It should return empty if not try to restart de computer. After it return empty you can install it:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

rvm command not found

I installed rvm with rails, from the official website of RVM, I specified the command suggested by the tutorial.
When the installation my system has rails 4.0.0, rvm 01/23/12, ruby 2.0.0, bundler gem 1.3.5 and 2.0.3
But I need to install ruby 1.9 to practice with a course that I am currently doing. "Rails for Zombies 2"
I try to execute the instruction rvm install 1.9.3 and the console returns this message:
rvm: command not found
Possible duplicate of: Ubuntu rvm setup issue
Your problem is that RVM is not loaded when you open a new terminal.
To solve this, run this command line: (if using login-shell)
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Or this (if using non-login shell):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
Or if you are using zsh (and/or oh-my-zsh):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.zshrc
This will add the path to RVM to load at each Terminal instantiation. You must either close and reopen your terminals or simply call source ~/.bashrc (or ~/.bash_profile or ~/.zshrc).
I had this problem after installing zsh. I'm a domain user so my $PATH and $HOME are not as straight-forward. What worked for me was
echo "source /usr/share/rvm/scripts/rvm" >> ~/.zshrc
The latest installation needs the users to be added to the Group rvm and then need to login again.
Please note that closing the terminal and reopening is not enough; the user has to logout and log back to take the Group addition in effect.
Adding the user to the Group can be done by:
sudo usermod -a -G rvm <user>
The binaries can also be at different locations based on the method you followed during the installation.
I had them at /usr/share/rvm/
You can also look at /usr/local/rvm/scripts/rvm
Then you add this line to the end of ~/.bashrc
[[ -s /usr/share/rvm/scripts/rvm ]] && source /usr/share/rvm/scripts/rvm
Note: If you are using a shell other than bash you may need to add the path accordingly.
For instance, if you using zsh shell add the above lines to the ~/.zshrc file.

Rails on Linux Mint 11

I have installed ruby via rvm on Mint 11 no problem. Installed gems, ditto. Installed rails via gem install rails, and when I type rails -v it returns the correct version. Until I close that terminal and reopen a terminal. When I do that and type rails -v I get the message
The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails
If I then type
rvm use 1.9.2-p180 --default
and then type rails -v I again get the correct version...until I close the terminal.
I should add that I have added a path statement to my .bashrc pointing to the 1.9.2-p180 directory in my .rvm directory.
Typing ruby -v always returns the correct version.
Create .bashrc file and add .rvm command
$ sudo touch ~/.bashrc
$ sudo gedit ~/.bashrc
(Add line to .bashrc file)
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
Logout and Login OR just update user profile from .bashrc with following command
$ . ~/.bashrc
Try adding this command to your .profile and reopening your shell:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
Use project rvmrc files. You can see how to set this up here http://beginrescueend.com/rvm/best-practices/
That way you keep all your gems seperate for each project and it's dead simple to set up
Try which rails. Maybe there is a link to a stub that gives you the note.
If that is the case calling the full path might help, e.g. /usr/local/bin/rails

RVM Command: source ~/.rvm/scripts/rvm

I'm going through the rails by example tutorial series. I'm trying my best to find solutions prior to asking questions, so if I have missed anything I apologise.
Every time I need to boot up RVM from the command line in terminal I need to punch a command so that RVM initialises: source ~/.rvm/scripts/rvm
Is this normal? It seems that I cant get the RVM commands to work unless I punch in this code prior. Note I only have to enter the command once, not every time I need to enter an RVM command.
Many thanks for your help.
Put this in your ~/.profile or ~/.bashrc:
# This loads RVM into a shell session.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
So you don't have to manually type it for every session.
Further Tip
If you want to use gnome terminal (comes as standard in Ubuntu) with rvm, you can do the following:
Edit the default profile. Check the following setting:
"Run command as a login shell"
This will stop loading the standard .bashrc by default. Fix this by making a soft link of .rvmrc pointing at .bashrc in your home directory
cd
ln -s .bashrc .rvmrc
Try closing terminal and then re-opening it to install a specific version of Ruby as seen in this video at 2:32.
For example, I typed curl -L https://get.rvm.io | bash -s stable --ruby
Then I quit and reopened the terminal, typed rvm install 2.2.3 and it worked.
If your rvm command is not found:
(to check, enter the command rvm list, which gives:)
/bin/bash: rvm: command not found
To solve it, follow these steps:
Install rvm
whereis rvm
rvm: /home/username/.rvm/bin/rvm
source ~/.rvm/bin/rvm
now test your rvm again
rvm list

Resources