Installing Ruby through RVM on Ubuntu 10.04.1 LTS - ruby-on-rails

I can't seem to get Ruby installed on my Ubuntu 10.04.1 LTS machine. I tried several different tutorials, and none of them worked. It seems like I can install RVM correctly using the command \curl -L https://get.rvm.io | bash -s stable. I do get this warning, though:
* WARNING: Your '/root/.bashrc' contains `PATH=` with no `$PATH` inside, this can breakRVM,
for details check https://github.com/wayneeseguin/rvm/issues/1351#issuecomment-10939525
to avoid this warning append #PATH.
When I try to run rvm install 1.9.3 I get the following and ruby doesn't install.
Downloaded archive checksum did not match, archive was removed!
If you wish to continue with not matching download add '--verify-downloads 2' after the command.
There has been an error fetching the ruby interpreter. Halting the installation.
I tried adding --verify-downloads 2, but that also didn't work.
I eventually want to install rails but, of course need to install ruby first.
Edit:
I also get /usr/local/rvm/scripts/functions/support: line 170: cd: /path/to/tarballs/: No such file or directory when trying to install ruby.

You should not work as root, this is insecure and you can easily get bitten by it, start using user accounts for work/deployment. You can remove the current installation with:
rm -rf /usr/local/rvm /etc/rvmrc /etc/profile.d/rvm.sh
The warning you get happens because in /root/.bashrc there is PATH=... it is intended to be there, you should just not use root account directly (look 1.)
The checksums problems: it was caused by manually downloaded/build ruby archive, rvm will prevent those unless you specify the flag (--verify-downloads 2) which means you trust the archive with not matching checksum.
For the cd issue: you have a file /etc/rvmrc or /root/.rvmrc which specifies rvm_archives_path=/path/to/tarballs - make sure to remove it (it could be gone already after 1.).

It looks like you missed the step of adding the path to your rvm/bin directory in your .bashrc or .bash_profile. Either one will work, here I'm using ~/.bashrc. Add the following line to the end of your ~/.bashrc and reload ~/.bashrc then give it a try.
# .bashrc
export PATH=$PATH:/usr/local/rvm/bin # This is default path
To reload your ~/.bashrc
$ source ~/.bashrc

Related

How do I completely uninstall ruby, rails, rvm, gems?

I am very new to Ruby on Rails. I have installed ruby, rails, gems, and RVM (and possibly some more RoR-associated files) via Mac OS terminal.
When I first installed these softwares, they seemed to work fine, and I could execute command lines like:
rails new 'project' or rails server
But then I messed around with git, directory, and some sudo bundle/gem commands a little bit because "bundle install" command wouldn't work. Honestly, I don't know what I have done, but all of these command lines have stopped working now.
They output various error messages, such as:
1) There was an error parsing 'Gemfile': Undefined local variable or method for Gemfile. Bundler cannot continue.
2) bash: /usr/local/bin/rails: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory
3) ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions
4) find spec_for exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
I think there were more errors, but these are all I can remember for now. Obviously, I am getting some intimidating error messages that I don't understand.
So I have come to a conclusion that I should uninstall all Ruby, Rails, Gems, RVM, and Homebrew files. But even this task looks very challenging to me.
I have tried numerous command lines in an attempt to delete them, but when I type in "rails" on spotlight, I still see lots of rails-associated files. Also, when I type "ruby -v" on terminal, it is still showing the ruby 2.0.0p648 version.
When I type in "which ruby" on terminal, it says "/usr/bin/ruby
When I type in "which rails" on terminal, it says "usr/local/bin/rails
In short, I just want to delete all of these RoR-related files, softwares, and every trace of them, and reinstall them clean. Please please help me. I do not want to give up coding. Is it too late to say that I'm sorry?
#This is my .bash_profile
# Enable tab completion
source ~/.profile
# colors!
green="\[\033[0;32m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
reset="\[\033[0m\]"
# Change command prompt
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# '\u' adds the name of the current user to the prompt
# '\$(__git_ps1)' adds git-related stuff
# '\W' adds the name of the current directory
export PS1="$purple\u$green\$(__git_ps1)$blue \W $ $reset"
alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export RBENV_ROOT=/usr/local/var/rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
~
"~/.bash_profile" 21L, 720C
Ruby is installed on OS X by default. So you don't want to remove that, there are things that might require ruby that has nothing to do with rails or your rails projects, you should ignore it. (and you should probably not use spotlight for finding dev files, its just confusing as to what is safe and what is not to play with)
Secondly, you'll hardly EVER use sudo for any rails-related work on your mac, so if a tutorial wants you to run that command, don't.
And lastly, its possible it's not as bad as you think. So there's 2 steps. 1 - Fix your rvm environment and 2 - fix your gemfile
TO RESOLVE
--Start be reinstalling RVM
\curl -sSL https://get.rvm.io | bash
Now because it's changed your shell environment (added variables and aliases) and because you've changed some things that are unpredictable... Log out, and log back into your mac.
** Which ruby is in use now? **
which ruby
If you're system is still showing /usr/bin/ruby then you'll need to edit your shell profiles. Because I don't know what you might have done, or what shell env you're using I'll just be thorough. Any excess won't hurt.
You'll review (in the editor of your choice) 4 hidden files in your home directory
/Users/yourhome/.profile
/Users/yourhome/.bashrc
/Users/yourhome/.zshrc
/Users/yourhome/.bash_profile
If you're using bash, then make sure your bash_profile has in it
source ~/.profile
In the bashrc nad zshrc files make sure the rvm path exists
export PATH="$PATH:$HOME/.rvm/bin"
In the .profile file make sure this command exists
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
-- Once you've saved your changes, log out and back in (you shouldn't have have to do this but again, just being thorough).
Once that is done, you should be able to install a ruby -
rvm install ruby-2.2.3
Now if you say rvm use ruby-2.2.3 and then which ruby, you should see a pointer to your home directory where rvm lives.
* Now to fix the Gemfile *
You have an encoding problem, which is what caused you the errors that made you see spots in the first place. If you paste the contents of the file here
(in a terminal in the directory of your rails project)
cat Gemfile
Paste those contents here and it can be fixed.

Ruby Rails Environment Completely Down about Paths, installation and brew

and Thank you for Helping me!
Long story short, I put this in the terminal
curl https://raw.github.com/gist/1688857/rbenv.sh | sh ; rbenv global 1.9.3-p327-perf
I ended up downloading/installing ruby over my current ruby/rails. I stopped it in time but it was too late. Both my rails and my ruby commands didn't work .....
Originally I installed railsinstaller to get my rails/ruby up and running.
I did rvm implode, removed rvm path in .bash_profile,
removed /etc/rvmrc file as well. I figured the rmv clash with the new ruby that I downloaded.
Originally I used railsinstaller to get ruby/rails up and running.
Then I tried to install railsinstaller but it didn't work! I later uninstalled railsinstaller because I want to try brew.
Here is my .bashrc profile
export PATH="/usr/bin:$PATH"
export PATH="/usr/local:$PATH"
export PATH="/usr/local/bin:$PATH"
export PATH=/usr/local/mysql/bin:$PATH
export PATH="/usr/local/opt/ruby/bin:$PATH"
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
Here is what I get when I run brew doctor
Warning: Setting DYLD_* vars can break dynamic linking.
Set variables:
DYLD_LIBRARY_PATH
Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.
You should probably change the ownership and permissions of /usr/local
back to your user account.
Warning: Experimental support for using Xcode without the "Command Line Tools".
You have only installed Xcode. If stuff is not building, try installing the
"Command Line Tools for Xcode" package provided by Apple.
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
autoconf
libtool
(I tried brew link above)
Error: Could not symlink file: /usr/local/Cellar/autoconf/2.69/bin/ifnames
/usr/local/bin/ifnames may already exist.
/usr/local/bin may not be writable.
same thing happen with libtool
Warning: Your Xcode is configured with an invalid path.
You should change it to the correct path:
sudo xcode-select -switch /Applications/Xcode.app
When I run brew install ruby .......
NOTE: By default, gem installed binaries will be placed into:
/usr/local/opt/ruby/bin
You may want to add this to your PATH.
Warning: Could not link ruby. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link ruby'
==> Summary
🍺 /usr/local/Cellar/ruby/2.0.0-p0: 877 files, 18M, built in 2.7 minutes
There are bash commands that I can not access. I have to source my bashprofile everytime to get some bash commands to work.....
I am new to rails and I am developing a rails app. The rails mvc concepts are easy to grasp, but I didn't pay much attention to.
-paths
-environments
-rbenv
-rvm
-brew
-bash commands
etc
This is the type of thing where you start making the app after installing everything and don't quite know how ruby/rails work under the hood when something breaks.
If someone can point me to the right direction. I will love your help. I will try to research this further myself.
Thanks!
If you need more info please let me know and thanks!
HI HERE IS MY UPDATE
Thanks! so I installed xcode,
I went through this tutorial
https://coderwall.com/p/auvm9g
and installed everything successfully but my computer can't find the ruby/rails that I installed. It came on when the installation finished but I lost it after I exit the terminal.
I did brew doctor
Warning: Setting DYLD_* vars can break dynamic linking.
Set variables:
DYLD_LIBRARY_PATH
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
Here is my .bashrc
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
export PATH="/usr/local:$PATH"ls
export PATH=/usr/local/mysql/bin:$PATH
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
Here is my .bash_profile
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into shell session *as a function*
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
PATH="/usr/local/bin:/usr/local/heroku/bin:/usr/local/mysql/bin:/usr/local/bin:$PATH"
ruby -v
rbenv: ruby: command not found
The `ruby' command exists in these Ruby versions:
1.9.3-p286
rails -v
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
1.9.3-p286
\curl -L https://get.rvm.io | bash -s stable --ruby
Upgrading the RVM installation in /Users/judyngai/.rvm/
RVM PATH line found in /Users/judyngai/.zshrc.
RVM sourcing line found in /Users/judyngai/.bash_profile /Users/judyngai/.zlogin.
Installing rvm gem in 1 gemsets ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
Upgrade Notes:
* WARNING: Above files contains `PATH=` with no `$PATH` inside, this can break RVM,
for details check https://github.com/wayneeseguin/rvm/issues/1351#issuecomment-10939525
to avoid this warning append #PATH.
* No new notes to display.
my .rvm and .benv are in my Users/judyngai/.rvm
I am pretty sure I have a paths problem, if someone can enlighten me I will be really happy and grateful!
You have a few things going on.
First off, I haven't used railsinstaller, but it looks like a bad deal. Many of these "one-click-install" applications end up leaving you in a mess like you have here. I recommend removing everything rails installer has done and following something like this guide to get you going: https://coderwall.com/p/auvm9g. That does each part separately.
But, if you want to try and fix what you got...
First, looks you have some issues with homebrew according to brew doctor. Largest of which is you need to install Xcode Command Line Tools.
That should also take care the autoconf and libtool warnings.
Looks like you also need change permissions on you /uar/local directory since that's where homebrew puts everything.
Second, installing Ruby through brew is a bad idea. I recommend either rbenv or rvm.

I am getting rvm: command not found after installation of rvm

I know the above question is very common question. I have gone through multiple posts on this topic. But I didn't get any resolution.
I have installed rvm locally. We already have the installation files. SO went into the folder and run the install command.
$ ./install
Then I checked ./rvm folder in the Users home folde
$ cd ~/.rvm
folder exists. Hence Installation is successful.
Now I am typing rvm in the command line
$ rvm
I am getting below exception
$ rvm
-sh: rvm: command not found
After reading the multiple articles in stackoverflow on this issue, I learned that I have to add the below lines in .bash_profile as I am using Mac OSX 10.7.3
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Even after I am getting same exception while typing rvm. Is there any thing extra I need to do? or Am I missing some thing? Please help
Steps to try out:
Log out and login to your system.
Open a new terminal and manually run
source $HOME/.rvm/scripts/rvm
then
rvm
Check these work-arounds.
Update:
To avoid running
source $HOME/.rvm/scripts/rvm
every time you open a terminal, include this line into ~/.MacOSX/environment in your Mac (This is similar to ~/.bashrc in GNU/Linux-based systems under $home aka ~ directory).
In my case, i am using Ubuntu Bash in Windows 10 and to fix the problem i used:
source /usr/local/rvm/scripts/rvm
For those that are doing this in 2018 just
add
source $HOME/.rvm/scripts/rvm
to your .bash_profile within your home directory.
you need to enable login shell in terminal emulator preferences, sometimes it is needed to use /usr/bin/bash --login, here is an example https://rvm.io/integration/gnome-terminal/
after enabling login shell you need to close terminal application and open it fresh.
I just had to open a new Terminal session.
After I installed it using:
curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm install 2.2
For Ubuntu 18.04, I had to run the command below to solve the issue after rvm was installed using instruction from here.
source /usr/share/rvm/scripts/rvm
This is one of other options available for RVM:
source /etc/profile.d/rvm.sh

"The program 'ruby' is currently not installed" error after reboot

After the reboot which was required to update all the packages,
ruby -v
doesn't work. It says rails is not installed either, but I guess it should be the similar issue. when I do:
sudo apt-get install ruby
It says the newest version is already installed.
When I do:
dpkg -L ruby
I get the following output:
/.
/usr
/usr/bin
/usr/share
/usr/share/doc
[and other stuff..]
But I realized $PATH already includes /usr/bin:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/usr/games:/home/ubuntu/.rvm/bin
May I know why I'm still getting the following error message?:
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt-get install ruby
My .bashrc already has this too:
PATH=$PATH:$HOME/.rvm/bin
dpkg will be checking in a database that it maintains, whereas trying to execute ruby uses the PATH. If I recall correctly, Ubuntu has a bash handler configured to execute when any command is unresolvable; it seems that it just displays that generic message rather than checking with dpkg first.
It is possible that ruby has disappeared from your filesystem (or at least the directory it previously resided in), or that your PATH was changed.
What do you get if you execute "which ruby" and "where ruby"?
Lastly, Ubuntu can complain that a program cannot be found when it is present. This occurs when running a 64-bit version of Ubuntu, without the necessary x86 libraries installed, and trying to execute a 32-bit binary. However, I recall the error message being more along the lines of "file not found".

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