Can't seem to "use" the RVM Ruby install - ruby-on-rails

I'm getting this error when I try to invoke rails, rails -v or rails -c:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
I installed RVM, used it to install Ruby 1.9.3, and switched to it rvm use 1.9.3 --default.
When I ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
I also gem install rails --no-rdoc --no-ri and checked...ls ~/ruby/gems/gems/:
actionmailer-3.2.8/ journey-1.0.4/ rake-0.9.2.2/
actionpack-3.2.8/ json-1.7.5/ rdoc-3.12/
activemodel-3.2.8/ mail-2.4.4/ rubygems-bundler-1.0.7/
activerecord-3.2.8/ mime-types-1.19/ rvm-1.11.3.5/
activeresource-3.2.8/ multi_json-1.3.6/ sprockets-2.1.3/
activesupport-3.2.8/ polyglot-0.3.3/ sprockets-2.4.5/
arel-3.0.2/ rack-1.4.1/ thor-0.16.0/
builder-3.0.0/ rack-cache-1.2/ tilt-1.3.3/
bundler-1.1.5/ rack-ssl-1.3.2/ treetop-1.4.10/
erubis-2.7.0/ rack-test-0.6.1/ tzinfo-0.3.33/
hike-1.2.1/ rails-3.2.8/
i18n-0.6.0/ railties-3.2.8/
And if I echo $GEM_PATH:
/home/flackend/.rvm/gems/ruby-1.9.3-p194:/home/flackend/.rvm/gems/ruby-1.9.3-p194#global
echo $PATH:
/home/flackend/.rvm/gems/ruby-1.9.3-p194/bin:/home/flackend/.rvm/gems/ruby-1.9.3-p194#global/bin:/home/flackend/.rvm/rubies/ruby-1.9.3-p194/bin:/home/flackend/.rvm/bin:/usr/local/jdk/bin:/home/flackend/perl5/bin:/usr/kerberos/bin:/usr/lib/courier-imap/bin:/usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/home/flackend/.rvm/bin:/home/flackend/bin
cat ~/.bashrc:
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
cat ~/.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" # Load RVM into a shell session *as a function*
So somewhere something has a path that says to look at the system Ruby install. Any ideas? Thanks!
EDIT
Okay, also, If i switch back to the system Ruby, rvm use system, and rails -v, I get:
Rails 2.3.8
So I have no idea at all what this error is indicating.

You have not completed rvm installation. You need add ~/.rvm bin paths before /usr/bin by command in .bashrc:
[[ -s "/Users/pftg/.rvm/scripts/rvm" ]] && source "/Users/pftg/.rvm/scripts/rvm".
To test just check $PATH env. Should be similar to:
/.../.rvm/gems/ruby-1.9.3-p125#global/bin:/.../.rvm/rubies/ruby-1.9.3-p125/bin:/.../.rvm/bin:/usr/local/bin

If you installed everything ruby as well as rails means, you may need to select the 'Run command as login shell' checkbox by doing following,
Open terminal
Go to Edit tab, then select Profile Preferences from the menu item.
The Profile Preferences window should be displayed, then select Title and Command tab.
Then select the checkbox Run command as a login shell.

I just used RVM to create a "gemset", switched to it, and tried installing Rails again and it works now.
https://rvm.io/gemsets/
I'm not sure why that fixed it or why it wasn't working before. I like when things work, but I would rather have figured out why it wasn't working with the #global gemset.
Thanks for all your help!

I had the exact symptoms described above as well and was stuck on this problem for quite some time (the ruby environment and dependencies are a horrible mess). I can't say I'm out of the woods yet but at least I'm picking up the correct version of rails now and gotten past this error.
I believe the real issue here is actually to do with zlib. It seems that it's a crucial component to separate your system version of ruby (v1.8 likely install via yum/apt-get) with the other versions or Ruby you need (installed via rvm) for other projects.
If you do not have zlib installed, or rvm is not using it correctly, then sometimes you will pick up the system ruby/rails and all sorts of strange errors occur.
If you DO have zlib installed (yum/apt-get install zlib) then the trick I discovered was that I specifically had to tell rvm which version of zlib to use when installing ruby.
rvm install 1.9.3 --with-zlib-dir=$rvm_path/usr

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.

Rails keeps telling me that it's not currently installed

I use rvm to manage different rubies and their gemsets. My shell is zsh with oh-my-zsh configured with basic settings. Enabled oh-my-zsh plugins are ruby, rails, osx, and git. Here's the command I used to install ruby-1.8.7 and rails-3.0.7.
rvm install 1.8.7
rvm use 1.8.7
gem install rails -v=3.0.7
and then I typed rails and got:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
I've tried more thorough installs also, Like reinstall rubygems after switching to ruby-1.8.7, or create a completely new gemset, but with no luck.
Here's the rvm info:
ruby-1.8.7-p352#rails:
system:
uname: "Darwin yicai.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
rvm:
version: "rvm 1.8.6 by Wayne E. Seguin (wayneeseguin#gmail.com) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2011-06-30"
platform: "i686-darwin10.8.0"
patchlevel: "2011-06-30 patchlevel 352"
full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]"
homes:
gem: "/Users/nil/.rvm/gems/ruby-1.8.7-p352#rails"
ruby: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352"
binaries:
ruby: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/ruby"
irb: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/irb"
gem: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/gem"
rake: "/Users/nil/.rvm/bin/rake"
environment:
PATH: "/Users/nil/.rvm/gems/ruby-1.8.7-p352#rails/bin:/Users/nil/.rvm/gems/ruby-1.8.7-p352#global/bin:/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin:/Users/nil/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/sbin"
GEM_HOME: "/Users/nil/.rvm/gems/ruby-1.8.7-p352#rails"
GEM_PATH: "/Users/nil/.rvm/gems/ruby-1.8.7-p352#rails:/Users/nil/.rvm/gems/ruby-1.8.7-p352#global"
MY_RUBY_HOME: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352"
IRBRC: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/.irbrc"
RUBYOPT: ""
gemset: "rails"
and the gem version is 1.8.10, the latest.
If you're running a rails command immediately after installing rails, you will need to restart your terminal before your commands will be recognized.
I had this problem today. Not completely related to your question, but since this page is what comes up in Google when I search for "Rails is not currently installed on this system", I thought I would add my answer:
What happened is that I was using ruby 1.9.2 with rails for a while, but then I needed to use ruby 1.8.7 to run some other script that I found.
Afterwards, I wanted to change by system back to using 1.9.2, and that's where the problem started:
$ rvm list
=> ruby-1.8.7-p352 [ x86_64 ]
ruby-1.9.2-p290 [ x86_64 ]
$ rvm use 1.9.2
I thought that would do the trick. But no, that gives me the "Rails is not currently installed on this system" message.
What I had forgotten is that I had configured rails using an rvm gemset. So I needed to specify the correct gemset when I was selecting which ruby version to make active.
$ rvm gemset list_all
gemsets for ruby-1.8.7-p352 (found in /Users/asgeo1/.rvm/gems/ruby-1.8.7-p352)
global
gemsets for ruby-1.9.2-p290 (found in /Users/asgeo1/.rvm/gems/ruby-1.9.2-p290)
global
rails31
$ rvm use ruby-1.9.2-p290#rails31
That did the trick.
Mac OS X, rbenv, and rails
I was getting the exact same issue but with rbenv rather than rvm. After verifying a correct .bash_profile.
.bash_profile
export PATH="$HOME/.rbenv/bin:/usr/local/bin:$PATH"
eval "$(rbenv init -)"
Restart the shell
exec $SHELL -l
Check the path
echo $PATH
Finally
I repeatedly installed and uninstalled rails but it was never placed in the .rbenv/bin directory after rbenv rehash. In the end I did a find . -name rails and uninstalled every gem that was returned and uninstalled rails. Then:
$ gem install rails
$ rbenv rehash
$ which rails
/Users/palmerc/.rbenv/shims/rails
I had the same issue and found that RVM was not showing as installed either if I tried the rvm command. All it took to fix both problems was running this command in the terminal
$ source ~/.rvm/scripts/rvm
Restart your terminal and then re-run your rails command
Rails is not reporting that it isn't installed. Your Debian system is telling you that rails isn't installed. One thing about rvm is that it relies on some complicated bash shell scripting and you sometimes need to start a fresh shell for changes to appear. You should also make sure that the correct rvm shell commands were added to your .zshrc file.
Also check your path to make sure the ~/.rvm/gems/... path in included.
I ran into this issue using rbenv. Turns out gem install rails did in fact install Rails but rails was not recognized as an executable. The fix for me was to run rbenv rehash.
I found this fix and more details on setting up Rails 5 at https://gorails.com/setup/osx/10.11-el-capitan
I have encountered this problem, but it has been resolved.
I use macOS, I do not use rvm, I only use HomeBrew, I first use gem env to get the installation directory of all gems, mine is:
$ gem env
RubyGems Environment:
   -RUBYGEMS VERSION: 3.1.2
   -RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-darwin19]
   -INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
   -USER INSTALLATION DIRECTORY: /Users/myname/.gem/ruby/2.7.0
...
Then you try to go to /usr/local/lib/ruby/gems/2.7.0 to find the executable file directory of the rails gem that you have installed, for example: /usr/local/lib/ruby/gems/2.7.0/bin, then add to the path environment variable
I found this problem but the solutions above didn't solve it. I am not using rvm (and I'm working on mac) and I had to update the path to add rails executable directory:
echo 'export PATH="/usr/local/lib/ruby/gems/3.0.0/bin:$PATH"' >> ~/.zshrc
I had a similar issue, but with rbenv.
I originally installed ruby on bash. Then I played around with .bashrc in VIM, messed that file up, and reset it back to default. In doing so, I unknowingly removed the exported rbenv $PATH. Because of this, my terminal no longer recognized that I had ruby installed.
I revisited the ruby installation page (https://gorails.com/setup/ubuntu/15.04) and tried to set up my rbenv path again with this command:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
It failed.
Luckily, I had already switched to zsh (with oh-my-zsh) between the time I messed up my .bashrc and the time I tried to access irb from my terminal.
My solution was to set up the rbenv path per the installation guide, but by replacing all instances of .bashrc with .zshrc like so:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
Hope this helps!
Here's what I've done. And the problem is gone. Hence I guess problem solved.
rvm use system
change to the system ruby. remove all gems in it using the command provided and explained here. then I install wanted ruby versions from scratch:
rvm install 1.8.7
rvm install rails -v 3.0.7
then bundle install
for further detail, might need dig into the gem install procedure.
add source ~/.rvm/scripts/rvm to your .bashrc file if rails installs fine but then you get the error "rails is not currently installed". This frustrated me for a while but I found the answer here: http://www.codelearn.org/blog/how-to-install-ruby-rails-screencasts-linux-mac-windows
I just reloaded my terminal
source ~/.bashrc
See: How do I reload .bashrc without logging out and back in?
Rbenv users
I had the same issue and this worked for me.
Setting the ruby version in the current directory.
rbenv local 2.7.1
Then I was able to run rails new
I had the same problem but the solution above didn't help.
This was my scenario
rvm list
=> ree-1.8.7-2012.02 [ i686 ]
ruby-1.9.3-p125 [ x86_64 ]
which ruby
/Users/dev/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby
which rails
/usr/bin/rails
gem list --local
..
rails (3.2.8)
rails2_asset_pipeline (0.1.20)
railties (3.2.8)
..
rvm use ruby-1.9.3-p125
which ruby
/Users/dev/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
which rails
/Users/dev/.rvm/gems/ruby-1.9.3-p125/bin/rails
By uninstalling rails and railties and reinstalling rails when using ree my problem was resolved.
Hope this helps others in my situation, not sure how I got into it :S
I had the same problem, I ended up deleting my .rvmrc rvm --create --rvmrc 1.8.7#project where the 1.8.7#project is whatever you want your ruby to be. cded in and out and it worked. http://sirupsen.com/get-started-right-with-rvm/
Just had same problem and couldn't find an answer. Here's what I did:
find current rails path
$ which rails
returns something like this: /usr/local/rails
Delete current version:
$ sudo rm -rf /usr/local/rails
Reinstall rails
$ sudo gem install rails
I ran into this same issue and none of the answers given helped so I thought I'd share my solution in case it might be useful for someone else.
I was messing around with my .profile and .bashrc files and along the way I messed up my RVM install. Still not sure exactly what I did, but the fix was easy. Just had to run the following command, which cleans up all of your system path settings for RVM:
rvm get [head|stable] --auto-dotfiles
Note that if you're running an old version of RVM this may upgrade your setup, which may not be what you want.
A possible solution is to not maintain two different configuration files .bash_profile and .bashrc
The solution as suggested in this excellent post on the difference between .bash_profile and .bashrc is to source .bashrc from your .bash_profile file, then putting PATH and common settings in .bashrc.
Quoting,
add the following lines to .bash_profile:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
end quote
I had this error after updating ruby. I had to run 'bundle install' to fix it.
Try to specify gemset explicitely in your Gemfile:
source 'https://rubygems.org'
ruby "2.2.3"
#ruby-gemset=rails424
Try This:
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use /bin/bash --login as the command.
$ bin/bash --login
$ rails -v
I had this message on my Mac:
Rails is not currently installed on this system. To get the latest
version, simply type:
and it was about the $PATH not being correct. The system has an outdated version of rails (/usr/bin/ruby). The path to your chosen version of ruby ($HOME/.rbenv/versions/2.3.0/bin) must precede the system's outdated version along $PATH var, like below:
export PATH="$HOME/.rbenv/versions/2.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
adjust it to your version of ruby.
For MacOS (High Sierra):
Tokaido is the Rails installer system recommended on the "Getting Started" Rails guide page for Mac OS. But it doesn't just install, it runs its own shell scripts. If you start out using that, which sources its own shell environment, then later start a terminal without launching from the Tokaido shell, this happens, because the "rails" command falls back to the original system rails code on the Mac.
For mine, the 'which rails' command in a normal terminal returns
/usr/bin/rails
But after launching Tokaido's shell, 'which rails' gives this path:
/Users/charlesross/.tokaido/Gems/2.2.0/bin/rails
Out of nowhere Rails wasn't currently installed but, what fixed it was
rvm use ruby-2.6.0
...and verified my path in .bash_profile
export PATH="$PATH:$HOME/.rvm/bin"
I was having this problem today. I haven't 100% solved it, but in new tabs I can do rvm use 2.5.5 and then rails -v works fine.
➜ my-repo git:(next_release) ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]
➜ my-repo git:(next_release) rails -v
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
➜ my-repo git:(next_release) rvm use 2.5.5
Using /Users/amberwilkie/.rvm/gems/ruby-2.5.5
➜ my-repo git:(next_release) rails -v
Could not find rake-12.3.3 in any of the sources
Run `bundle install` to install missing gems.
➜ my-repo git:(next_release) bundle install
I was looking through the source and found another error message that suggested the user run the following command.
I ran the command and everything now works. None of the suggestions above worked for me. Run the command from inside your newly created Rails app.
gem pristine --all
Here is how it worked for me:
Intall rvm in mac by following the mac installation instruction
rvm install ruby
gem install rails
rails --version
For me ( MacOS Monterey, rbenv) adding rails version to gem install command get the problem resolved.
you can find a specific version of rails that matches to your ruby from this link and replace the VERSION .
gem install rails -v VERSION
rbenv rehash
after successful installation, then rails should be added to /Users/your_user/.rbenv/shims
Also plz check that your shims directory should be the first element of your path.
➜ ~ echo $PATH #
/Users/ario/.rbenv/shims: ...
I was following along with the Odin Project ruby-on-rails course by
installing rbenv,
adding eval "$(rbenv init -)" to ~/.zshrc
installing rails gem
attempting to run rails new my_first_rails_app
But I had forgot to run source ~/.zshrc after editing the file, so I was seeing the error:
Rails is not currently installed on this system.

rvm not found while installing Ruby on Rails

I have been following the tutorial to install Ruby on Rails on the mac from this website:
http://ruby.railstutorial.org/
I installed rvm and it wasn't working. The tutorial said to enter this command:
~ $ [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
After I did that it seemed to have loaded successfully as it said this:
~ DUFF$ rvm reload
RVM reloaded!
~ DUFF$ rvm notes
Notes for Darwin ( Mac OS X )
For Lion, Rubies should be built using gcc rather than llvm-gcc. Since
/usr/bin/gcc is now linked to /usr/bin/llvm-gcc-4.2, add the following to
your shell's start-up file: export CC=gcc-4.2
(The situation with LLVM and Ruby may improve. This is as of 07-23-2011.)
For Snow Leopard be sure to have Xcode Tools Version 3.2.1 (1613) or later
You should download the latest Xcode tools from developer.apple.com.
(This is since the dvd install for Snow Leopard contained bugs).
If you intend on installing MacRuby you must install LLVM first.
If you intend on installing JRuby you must install the JDK.
If you intend on installing IronRuby you must install Mono (version 2.6 or greater is recommended).
To seamlessly abandon the Apple-installed system ruby (ruby 1.8.7 patchlevel 174 for Snow Leopard):
rvm install 1.8.7 # installs patch 302: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system # migrate your gems
rvm --default 1.8.7
NOTE: For all installations, as of 1.7, RVM no longer autoloads .rvmrc files. In order to return this functionality, you MUST add 'export rvm_project_rvmrc=1' to your $HOME/.rvmrc file. This causes RVM to override 'cd' which, while toggleable even < 1.7, is currently defaulted to 'off'. This knob returns the previous behaviour to active which causes per-project .rvmrc files to be loaded once again.
Example: echo 'export rvm_project_rvmrc=1' >> $HOME/.rvmrc && rvm reload
So after all of that I entered this as directed:
type rvm | head -n1
and it said:
-bash: type: rvm: not found
So after that long introduction my question would be do you know why it is not recognizing the rvm type after it seemed to have installed. I am a complete newbie so please be gentle. I have been having a ton of issues and this seemed to be moving along nicely up until this point.
Any help would be appreciated. Thanks.
Are you following this tutorial? http://beginrescueend.com/rvm/install/
You should run this entire command:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
That way it's appended to your .bash_profile file, and loaded in every new terminal. The command you entered will only load the rvm function for a single terminal session.
.rvm/scripts/rvm is a shell script itself that loads all necessary functions into your environment.
Have a look at the same question I posted some time ago.
The install guide says to "register" RVM in the terminal this way:
user$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
Basically, when you load the RVM function in your shell, where you're going to put the instruction depends on your distribution; here it's going into .bash_profile.
As a user of Ubuntu, I found using .bashrc instead of .bash_profile worked better.
The difference between .bash_profile and .bashrc is outlined here: http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html

RVM finding system gems' executables

I have installed RVM along with ruby versions. However if I fire up the console and run the command rails server, bundle install, etc. I get this error
bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory
But if I run rvm use 1.9.2 first, then everything is ok. I tried using `rvm use --default 1.9.2' but nothing changed. Does this mean it uses a different ruby from the ones in RVM? Thanks in advance!
Explanation of rubygems bin folders and PATH
Oh. You didn't have rails installed in your rvm ruby, but you did in your system ruby.
Individual gems, like rails can have a bin directory that will contain executable helper scripts. Your system default rubygems is making symlinks from your system /usr/bin/ dir into the gem's bin folder for these helper executables.
RVM provides a similar facility, except instead of polluting the system /usr/bin dir, it just appends its ~/.rvm/gems/#{rvm_gemset_string}/bin folder to the PATH environment variable.
Importing system Rubygems list into your new rvm rubies' gem directories
RVM by default will not import your gems from your system ruby installation into your rvm ruby installs. It makes a full clean fork of the entire ruby system including rubygems (the gem 'rubygems') and rubygems' gem list. When you rvm install 1.9.2 it's like you've made a completely new install of everything used with ruby.
If you'd like to get all your system ruby gems that you were previously using into your preferred rvm ruby, try this:
rvm use system
rvm gemset export system.gems
rvm use 1.9.2
rvm gemset import system.gems
#You'll now have all your system gems reinstalled to your new ruby version
Original Answer/ Edits from #Telemachus
Try moving the lines that source rvm to the end of your ~/.bash_profile or ~/.bashrc (whichever you have it in):
'[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function'
.
bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file ...
| | ^--------------------------------\
^ Bash, not rvm; ^/usr/bin/rails, not ~/.rvm/gems/*/bin/rails; |
Some ruby leftover from a previous install in the os
You have rails installed in /usr/bin, which is probably before the rvm ruby bin path in your bash echo $PATH variable, so it's finding the system rails install (/usr/bin/rails, a ruby script) which starts like this:
#! /usr/bin/ruby18
You've gotta make the conflict stop happening, the best of all possible ways is making sure that RVM's bin dir is at the beginning of your PATH. This happens in the #Load rvm environment script that you added to your ~/.bash_profile when installing rvm. If you installed rvm as a system library rather than just for your user, this will be different.
If you get to that case, ask #Telemachus.
You'll then need to ensure you've gotten the rails gem installed in your new rvm ruby as above.
Acceptance Test:
You'll find that when you've done rvm use 1.9.2, then which ruby will return something like ~/.rvm/rubies/1.9.2/bin/ruby, and which rails should return something like ~/.rvm/gems/*/bin/rails.
I just solved the same problem on Windows Vista.
My console was giving me this message:
$ rails -v
sh: /c/RailsInstaller/Ruby1.9.2/bin/rails: C:/Projects/railsinstaller/Stage/Ruby1.9.2 /bin/ruby.exe: bad interpreter: No such file or directory
I just edited the first line of this file:
C:\RailsInstaller\Ruby1.9.2\bin\rails
And made it point to the correct location for ruby.exe, on my system, like this:
#!C:\RailsInstaller\Ruby1.9.2\bin\ruby.exe
Et voilà, problem solved!
You need to run rvm use --default 1.9.2, not just rvm use --default.

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