How to update Ruby on Ubuntu 10.10? - ruby-on-rails

Apologies in advance if this is a too nubs problem.
One friend got Beginning Rails 3 and we started playing Ruby using it (as .net developers!). I have installed Ubuntu 10.10 on VMWare Player - which apparently already had Ruby 1.9.2. Based on instructions in the book (with some quirks for total linux nubs) we managed to install Ruby 1.9.1 (ruby --version -> ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]).
But Rails (latest version - 3.0.2 I think) insist that Ruby 1.9.2 is better for our health!
So: How to update Ruby on Ubuntu 10.10? I want just this one ruby be there.

I recommend Ruby Version Manager.
Install (yes, it takes a leap of faith):
$ curl https://get.rvm.io | bash
then
$ rvm install 1.9.2
$ rvm use 1.9.2

The recommended way to manage Ruby versions is through RVM: http://rvm.io/
Rails is right about the Ruby versions, btw.

Related

Cannot update ruby version

I've just started learning RoR and I've come across a problem.
ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
But when I try to install version 1.9.3 this is what happens:
rvm install 1.9.3
Already installed ruby-1.9.3-p484.
To reinstall use:
rvm reinstall ruby-1.9.3-p484
Sorry if it's a noob question, I've just started learning.
I'm running Elementary OS (Ubuntu based distro)
Make ruby 1.9.3 default, or even better use ruby 2.1 if you are just starting with Rails 4.2
rvm --default use 1.9.3
or better
rvm install 2.1
rvm --default use 2.1
Ruby 1.9.3 is already installed. To use it, write
rvm use 1.9.3
To make it the default version, use
rvm --default use 1.9.3
And to get all your ruby versions installed, use
rvm list
Since RVM performs non-standard installs, the new version won't be automatically chosen.
You have to explicitely "enter" the new Ruby environment with
rvm use 1.9.3

Ruby version - Error installing Rails

I'm getting the next error installing RoR
How can I set the correct Ruby Version?
#####:path$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
#####:path$ sudo gem install rails
ERROR: Error installing rails:
activesupport requires Ruby version >= 1.9.3.
#####:path$
You shouldn't have to use sudo with gem install .... That's what's causing the mismatch between Ruby versions, since root is using the default installed Ruby, whereas your own account is using RVM's installed version.
Updating the system version of Ruby depends on your operating system, and usually lags behind the very latest version of Ruby. I've been using 2.0 for my latest project I launched last month. I doubt big OS vendors like Ubuntu or Apple are providing that version in their latest distribution. It's best that you manage your own Rubies whenever possible.
To install 1.9.3 you can run:
$ rvm install 1.9.3
then later
$ rvm use 1.9.3
You have :
###:path$ ruby -v
.....
###:path$ sudo gem install rails
...you said in your comment that :
$ sudo ruby -v
...gives you
ruby 1.8.7
To resolve this problem you shouldn't use sudo, as it tries to install using root session with 1.8.7 ruby version which is not supported.
To install rails just type the following without sudo:
$ gem install rails
...it should works as you've a supported ruby version (ruby 2.0.0p247)
You can check Install Ruby on Rails · Ubuntu Linux instructions (Which I found useful) if you've more troubles.

Which Ruby version am I really running?

I'm running Ubuntu 12.04 LTS, and installed Ruby via RVM.
The problem is, when I type ruby -v into the terminal, it says that my Ruby version is 1.8.7, and using the shotgun gem for Sinatra also says that I'm running Ruby 1.8.7.
But when I type rvm list it shows that the only version of Ruby that I have installed is 2.0.0 and it is my current and default version.
I installed Ruby 2.0.0 via RVM and it is the only version I had installed on my machine.
Now when I tried to install Rails 4 but got an error saying that I need Ruby 1.9 or higher.
How do I know what version am I really on, and how do I set 2.0.0 as my only version?
On your terminal, try running:
which -a ruby
This will output all the installed Ruby versions (via RVM, or otherwise) on your system in your PATH. If 1.8.7 is your system Ruby version, you can uninstall the system Ruby using:
sudo apt-get purge ruby
Once you have made sure you have Ruby installed via RVM alone, in your login shell you can type:
rvm --default use 2.0.0
You don't need to do this if you have only one Ruby version installed.
If you still face issues with any system Ruby files, try running:
dpkg-query -l '*ruby*'
This will output a bunch of Ruby-related files and packages which are, or were, installed on your system at the system level. Check the status of each to find if any of them is native and is causing issues.
Run this command:
rvm get stable --auto-dotfiles
and make sure to read all the output. RVM will tell you if something is wrong, which in your case might be because GEM_HOME is set to something different then PATH.
The ruby version 1.8.7 seems to be your system ruby.
Normally you can choose the ruby version you'd like, if you are using rvm with following. Simple change into your directory in a new terminal and type in:
rvm use 2.0.0
You can find more details about rvm here: http://rvm.io
Open the website and scroll down, you will see a few helpful links. "Setting up default rubies" for example could help you.
Update:
To set the ruby as default:
rvm use 2.0.0 --default
If you have access to a console in the context you are investigating, you can determine which version you are running by printing the value of the global constant RUBY_VERSION.

Rails and Ubuntu reporting different ruby versions

I use Vagrant and Chef to create new servers when I am developing. I want to start out on Ruby on Rails so I am setting up a server. Everything is working but Ubuntu and Rails are reporting different Ruby versions.
Ubuntu 12.04: ruby -v = ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
Rails = 1.8.7 (x86_64-linux)
I don't want Ruby 1.8.7 on the system at all but I can't get rid of it. Is there anyway to set a default Ruby version?
I don't want top use RVM or similar.
try this aptitude purge ruby
and then install the latest version or the version you want
came across this post in stackoverflow
How do I make Ruby 1.9 the default Ruby on Ubuntu?
This did the trick.
https://github.com/royratcliffe/VagrantBaseBoxes

Can I have/use different Versions of rails in the same machine

I am actually reading a rails book that is written for rails 2.3.5. I want to test Rails 3 beta as well. Is it possible to have such a setup in my Mac OS leopard?
I have tried with gem list -d rails. There are many versions stored in my mac but I don't know how to use different versions of rails while creating applications using rails command
While RVM is great there's no need for it in this use-case.
Install the Rails 3 gem: gem install rails—pre
Create new project: rails project_name (this will use the latest version installed)
To create projects with a specific version: rails _2.3.5_ project_name
Yes! Try rvm. It is awesome, you can have many different versions of Ruby, and for each one you can have different versions of gems. And you can run the same tests on all those versions. Isn't that cool?!
Quick How-To:
$ rvm install ruby-1.8.7 --default
$ gem install rails -v 1.0.0
$ rvm gemset create rails238
$ rvm 1.8.7#rails238
$ gem install rails -v 2.3.8
Now,
$ rvm 1.8.7
will give you ruby 1.8.7 and rails 1.0
And,
$ rvm 1.8.7#rails238
will give you ruby 1.8.7 and rails 2.3.8
You can make 2.3.8 as default one with
$ rvm use 1.8.7#rails238 --default
BTW rvm is documented really good.
The way to do this anymore is to use RVM, the Ruby Version Manager, which isolates different Ruby environments from each other.
A coworker of mine did a blog entry on setting up Rails 3 and RVM (and Ruby 1.9), which you might find interesting.

Resources