7

I want o install ruby 2.0 and I have followed many tutorials, but none of them works, and the defaul repo apt-get install ruby brings me the 1.8 version (and due is debian has restrictions to update it if is not through the repo) any way to do it?

Ive tried this way

cd /usr/src
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar xjf ruby.xxx.tar.bz2
cd rubyxxx
./configure --enable-shared
make 
make install

and just that, I get error on the next steps, when I make a ruby -version I get this

-bash: /usr/bin/ruby: No such file or directory

the end of the tuto install

cd ext/openssl/
ruby extconf.rb
make install

cd ../readline/
ruby extconf.rb
make install

gem update --system

any idea how to do this in debian 6? thanks

jpganz18
  • 5,508
  • 17
  • 66
  • 115

2 Answers2

6

Compile it from the source.

Go here: https://www.ruby-lang.org/en/downloads/

Get the latest stable Ruby 2.x, download the tarball, and compile it. You will be surprised that everything will actually work out of the box, except that you'll have to reinstall the gems once you upgrade to 2.x. Your 2.x will be installed into /usr/local/bin/ruby, so in some of my local scripts, I had to change the shebang to #! /usr/local/bin/ruby to get them work with 2.x. Ruby 1.9.3 will continue being available under /usr/bin/ruby. I'm no theorist or core developer, but this is my experience as a user. And while most gems work with 2.x perfectly, some more complicated ones (such as watir-webdriver), I wasn't able to get working with it, so I still keep 1.9.3 around.

(Update: Now with higher versions of 2.0 and 2.1 in sight, most developers whose gems are alive already adapted to Ruby 2.x.)

Boris Stitnicky
  • 12,444
  • 5
  • 57
  • 74
5

If it's a server, you may want to take a look at RVM (https://rvm.io/). It would make your install as simple as :

curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled

Martin
  • 7,634
  • 1
  • 20
  • 23
  • RVM allows you to easily change of Ruby version, even hosting several different if needed. Ruby 2.0 is now the default installed version using RVM. – Martin May 02 '13 at 19:03
  • 6
    I'm very sorry, but why should be RVM used at the server? It makes no sense and in fact, crutch for pushing Ruby to environments, which haven't ability to run multiple Rubies. So why RVM at the server? At least to compile it is much more clearer solution and cleanliness is next to godliness just at the server side. The only problem is, jpganz18 hasn't /usr/local/bin in PATH, IMHO. – Martin Poljak Oct 16 '13 at 15:00
  • @MartinPoljak RVM was actually built for the server; see Myth #4 at https://rvm.io/rvm/myths – Max Dec 29 '13 at 21:56
  • 2
    @Max Despite it, it makes no sense to me. Certainly, it has some particular uses in some kind of more special server deployments, of sure, but generally, the RVM server deployment despite the promises in Myths highly increases complexity of the environment by adding homogenizing layer which tries to solute something, which is hardly necessary to solute. The fact, hammers exist in the world doesn't mean, everything is necessary to solute using hammers. – Martin Poljak Nov 28 '14 at 10:08
  • RVM was no good solution for me. In spite using it on a client machine, it just made things complicate and did not work in the end. So I will not second the statement "RVM allows you to install easily ..." -- installations just did not work on my system. I had to kick it from the machine -- I just lost a lot of time with it. Now I compiled and installed Ruby 2.3.1 from the sources and it seams to be fine. RVM is not worth the trouble, if you just want to have the newest Ruby on your system. Compilation works just without any hassle on Wheezy. – Juergen Jun 24 '16 at 12:30