Can't find Ruby 1.9.2 after installing RVM - ruby

I'm on Linux Ubuntu 12.04, and I first installed Ruby 1.9.2.
After I tried installing rvm to use Octopress, ruby --version in bash results in ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
How can I use RVM with ruby 1.9.2?
I don't really understand what RVM is all about...

The 1.9.2 version you installed first is not accessible from rvm.
While working with rvm, only the list of rubies installed through rvm is served. The previously installed versions of ruby - while still present in the filesystem - are not included.
With the steps you have done so far, you have a 1.9.2 version installed in one location, and a 1.8.7 version installed as part of rvm.
Install 1.9,2 version by running the rvm install 1.9.2 command. After that, when you run the rvm list command, you should see an output similar to the following:
$ rvm list
rvm rubies
ruby-1.8.7-p358 [ i686 ]
=* ruby-1.9.2-p320 [ x86_64 ]
# => - current
# =* - current && default
# * - default
You can switch between different versions of ruby managed by rvm with the rvm use 1.8.7 / rvm use 1.9.2 commands.
Here's a short blogpost with a good intro to rvm: Get started right with RVM

RVM is a version manager which enables you to decide which of multiple installed Ruby versions you want to use in your current shell session. RVM does this by providing a shell function named rvm which can be used to switch between versions in the current session. This changes environment variables, especially the GEM_HOME and PATH, to match the currently selected Ruby installation.
Every installed Ruby version can be selected by a specific identifier string. If you had a system-wide Ruby installation already before you installed RVM, that one should be referenced by the string system. The newly installed version in your case should be called 1.9.2.
To make RVM work as intended, it is necessary to load the rvm shell function into your shell. How to do this is described in the RVM Installation Documentation in section 2 - "Load RVM into your shell sessions as a function".
You can see if the shell function is correctly loaded when the command type rvm | head -n1 responds with:
rvm is a shell function
If not correctly loaded it will tell you something like this:
rvm is /home/someone/.rvm/bin/rvm
If you finally have it working you can switch your active Ruby version with commands like rvm 1.9.2 or rvm system. You can get a list of all Ruby versions and their identifier strings recognized by RVM by the command rvm list.
You can also specify which Ruby version shall be enabled in all new shell sessions from the beginning by issuing the following command once:
rvm --default 1.9.2

Perhaps you have not yet switched to the ruby version with:
rvm use 1.9.2 (assuming you did rvm install 1.9.2)
for a more general explanation I gave an answer here which might help.

Related

Installing Ruby 2.2.3 on Ubuntu

This problem probably has an obvious answer to anyone who has used Ruby on linux for a long time, but I can't really get a good answer via Google.
I'm trying to check out the Rails 5 beta, which requires Ruby 2.2.2 or greater. I've installed the RVM (Ruby Version Manager) and set my ruby version to 2.2.3. Running rvm list in the terminal results in the following output:
rvm rubies
=* ruby-2.2.3 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Okay, great. I have Ruby 2.2.3 installed. Let's try bundle update:
Installing rack 2.0.0.alpha (was 1.6.4)
Gem::InstallError: rack requires Ruby version >= 2.2.2.
Okay, that's weird. What version of ruby do I have? Running ruby -v gives me this:
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
So... do I have 2.2.3 or not? What gives?
Since you are using bundle, I would suggest you to check your Gemfile for ruby version. You can also test it with bundle exec ruby -v
Also try:
rvm use ruby-2.2.3
bundle exec ruby -v
Maybe by setting the default Ruby version on rvm to the one you have (ruby-2.2.3) solves the problem, by doing rvm --default use ruby-2.2.3. Then reload the bash and execute ruby -v to check if the default version of Ruby was changed properly and then try again to execute the bundle install command.
If you don't know zsh and oh-my-zsh, I highly recommend for this kind of things. You could configure the terminal in order to show you the current version of Ruby and Rails that you're using every moment. Check it here: http://ohmyz.sh/
In addition to doing rvm use --default 2.2.3 or rvm use 2.2.3 make sure that you don't have the ruby package from apt (or whatever package manager) still installed. For some reason, that ruby package could take precedence over an RVM Ruby.
Also, try doing rvm uninstall 2.1.5 to force your system to default to 2.2.3... You can always reinstall 2.1.5 later and, if this issue persists, 2.2.3 should stick as your default.

DIfferent versions of ruby in ubuntu

I recently started following M Hartls tutorials on how to build a simple app using RoR.
I nearly wasted one full day on installing RVM and the ruby, since the default RVM on ubuntu is buggy. Once I install ruby through RVM
curl -L https://get.rvm.io | bash -s stable --ruby
it says it installed ruby 2.x version.
but when I type
ruby -v
It says the ruby version is 1.8.x. Why is that?
Your default ruby version is set to 1.8.x.
Type "rvm list" to list installed ruby versions "*" will appear next to your default.
Type "rvm use x.x.x" to use a different version of ruby.
To set a different default version of ruby type "rvm --default use x.x.x".
I think you missed the message given after installing RVM. It's something like:
Please make sure the following line is somewhere in your .bashrc:
source /home/<username>/.rvm/scripts/rvm
What is the output of ruby -v after you executed that line in the console?
If you are using RVM then:
do
rvm list
this will show list of installed rubies
and the do
rvm use XXXXXXX
XXXXX means the version you want to use from the list.
This will use the specified ruby. but after opening new terminal it might be again changed automatically. To avoid this use :
rvm use XXXXXX --default
For example of mine system:
rvm list
rvm rubies
ruby-1.9.3-p545 [ x86_64 ]
=* ruby-2.0.0-p451 [ x86_64 ]
# => - current
# =* - current && default
# * - default
$ rvm use 2.0.0
Using .rvm/gems/ruby-2.0.0-p451
$ rvm use 2.0.0 --default
Using .rvm/gems/ruby-2.0.0-p451

installing RubyGem on CentOs 5

My ultimate goal is to install Sass.
To do this I need to install RubyGems
To do this I need to install Ruby.
I installed Ruby with yum.
I then tried to install gem with yum yum install rubygem
The response is "nothing to do" and yet when I write gem install sass I get:
gem: command not found
I decided to try to install rubygems 2.2.2 manually. After downloading it, I tried to run ruby setup.rb and in response I get:
Rubygems now requires Ruby 1.8.7 or later
But yum does not seem to be able to install anything later than 1.8.5.
So now I'm trying to do this manually.
I downloaded Ruby 1.9.2 to my home directory and followed these instructions: http://howboring.com/post/1226760251/centos-5-and-rails-3-and-ruby-1-9-2
This seems to work, but the problem is ruby1.9.2 is installed in my home directory (i.e. ~/ruby1.9.3 not system wide.
Thus in the directory where I installed ruby 1.9.2 ruby -v still gives 1.8.5 but ./ruby -v returns 1.9.2. And which ruby returns /usr/bin/ruby (I suppose I could replace this with a symlink that points to ~/ruby1.9.2/ruby but this doesn't seem like a "best practice")
So my main question is where should install ruby 1.9.2 with Root Permissions so that 1.8.5 is replaced with 1.9.2 system wide.
My corollary question is: is there any easier way to do this? (perhaps install sass without install rubygems??)
I then tried to install gem with yum yum install rubygem
You have a typo in the package name, it is actually named rubygems.
Can i suggest Wayne Seguins excellent rvm (ruby version manager). As the home page states:
"RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems".
Site has comprehensive installation instructions. I've posted a truncated Set of instructions for installing on POSIX systems below, but please refer to the projects' home page as:
"we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods."
Install RVM (development version):
\curl -sSL https://get.rvm.io | bash
Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command:
user$ source ~/.rvm/scripts/rvm
test the installation was successful:
user$ type rvm | head -n 1
this should output "rvm is a function"
List all known rubies:
rvm list known //this will output a large list of rubies shortened here
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1[.1]
[ruby-]2.1-head
ruby-head
...
install the version you want:
rvm install 1.9.2
You can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby:
rvm use 2.1 --default
You can also temporarily use another version of your ruby versions
rvm list known //lists system available rubies
Choose to use another ruby
rvm use 1.9.3
RVM is a great tool, well documented, and actively developed, it handles a wider scope of functionality than i can list here, and it's a tool I use everyday.
You can use rbenv to install ruby and rubygems that you need
https://gist.github.com/jpfuentes2/2002954

ruby 1.8.7 & ruby 2 without rmv, failed instalation

I installed ruby 2.0 (from sources) in a centos that already had ruby 1.8.7.
I did not know that there was a previous installation.
I also noticed that had installed RVM. Now it doesn't work.
The RVM output
$ /usr/local/rvm/bin/rvm list
$ rvm rubies
No rvm rubies installed yet. Try 'rvm help install'.
From what I understand, RVM does not know there is already a installed version of Ruby.
Is possible uninstall all versions and reinstall ruby with RVM?
RVM allows "mounting" system rubies:
rvm mount /path/to/ruby
Or assuming all rubies are added to PATH
rvm automount
RVM will find any ruby binary available on PATH and will add it to rvm list
RVM does not care for rubies installed at the system level. It installs rubies to RVMs own folder inside of the users home directory. You should just install the desired ruby version using RVM. Since the RVM rubies should have precedence over the system-installed ruby, that should work out just fine.

How do I associate a new rvm install with existing ruby versions?

I was having a problem with RVM, so I uninstalled and re-installed it.
The truth is I actually tried rbenv, but that didn't work out for me so I am trying to get rvm up and running again - without having to install duplicate versions of Ruby.
I have at least 1 existing version of Ruby installed:
ruby --version
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
But when I do rvm list I get a blank list:
bash-3.2$ rvm list
rvm rubies
# Default ruby not set. Try 'rvm alias create default <ruby>'.
# => - current
# =* - current && default
# * - default
So my question has two parts:
How do I see all the versions of Ruby on my system (given that rvm is not showing me any)?
How do I associate the new RVM install with the existing versions of Ruby?
Or am I better off removing all existing versions of Ruby and re-installing everything? That seems like a pain in the ass though.
You can add an existing ruby to rvm using:
rvm mount /path/to/ruby
or:
rvm automount
but be careful as ruby installed in system might have hardcoded paths for gems - so gemsets would not work with it.
There is also new way of adding binary rubies (already compiled), for list of available builds for your platform run:
rvm list remote
and you can install those rubies using:
rvm mount -r 1.9.3
This might be default way of installing ruby to avoid compilation in next stable release of RVM - but it will work only for ruby 1.9.3+.
You don't want to associate RVM with an existing Ruby, you just want to install a new Ruby.
You don't want to remove the system Ruby, either; OS X depends on it.
Install a new 1.8.7 under rvm, this way you can associate your own gemsets with it. Let OS X manage the default system Ruby, you just ignore it and use your own, managed solely by rvm.
(If you decide to go the rvm route.)

Resources