Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

July 19, 2006

Installing Ruby on GNU/Linux(Gentoo, (K)Ubuntu, Fedora, SUSE) And MS Windows

Filed under: GNU/Linux, Gentoo, Ruby/Rails, Ubuntu — tabrez @ 12:05 pm

Installing Ruby on Gentoo:

To install Ruby on Gentoo, run the following command(as root) in a shell:

sh# emerge ruby ruby-mode

You can add a few ‘USE’ keywords if you want to install additional Ruby support(like database integration, CGI support etc). Add the following line to the /etc/portage/package.use file(keywords that are already present in ‘USE’ flag of /etc/make.conf file need not be added):

dev-lang/ruby docs examples fastcgi mysql

‘ruby-mode’ adds the ruby mode to the Emacs editor while editing .rb files. Use ‘ruby-modes’ to add similar support to XEmacs. You need to add some text to .emacs file from your home directory; see this to know how to do it.

Installing Ruby on (K)Ubuntu:

Preparation:

A little note before you start installing Ruby on (K)Ubuntu:
There are two versions of Ruby available in the Ubuntu repositories:

  • Ruby 1.8.4
  • Ruby 1.9.0

1.8.4 version can be installed by appending 1.8(Eg. ruby1.8, irb1.8 etc) to the respective package names. Similarly, 1.9 version can be installed by appending 1.9(Eg. ruby1.9, irb1.9 etc) to the respective package names. If nothing is appended(Eg. ruby, irb etc), what debian considers as default version of ruby(currently 1.8.4) will be installed.

Once Ruby is installed, the command to invoke the Ruby interpreter would depend on which version of it is installed. Like, if ruby1.8 is installed, ruby can be invoked using ‘ruby’ or ‘ruby1.8′ commands(‘ruby’ will be a symbolic link to ‘ruby1.8′):

sh# ruby1.8 first.rb
sh# ruby first.rb
sh# ls -l `which ruby`
lrwxrwxrwx 1 root root 7 2006-07-18 18:47 /usr/bin/ruby -> ruby1.8

(the quotes in the third command are inverted quotes and not single quotes)

Use ‘ruby1.9′ if 1.9 version is installed.

If all this sounds confusing, just follow my recommended way of installing Ruby and skip the ‘Optional’ part.

My recommended way of installing Ruby on (K)Ubuntu:

To install Ruby on Ubuntu family of operating systems, type the following command in a shell:

sh# sudo apt-get install ruby ruby1.8 libruby1.8 irb irb1.8 rdoc rdoc1.8 ri ri1.8 ruby1.8-examples ruby1.8-elisp ruby-manual rubybook

(Or search and install these packages using Synaptic(on Ubuntu) or Adept(on Kubuntu) Package Manager.)

Running commands like ‘ruby’, ‘irb’ etc will invoke the latest stable versions:

sh# ruby -v
ruby 1.8.4 (2005-12-24) [i486-linux]
Optional

To install the 1.9 version(which is not stable as of now), use the following command:

sh# sudo apt-get install ruby ruby1.9 libruby1.9 irb irb1.9 rdoc rdoc1.9 ri ri1.9 ruby1.9-examples ruby1.8-elisp ruby-manual rubybook
sh# ruby -v
ruby 1.9.0 (2006-04-21) [i486-linux]

Of course you can also have both 1.8.4 and 1.9 versions installed on the system at the same time. Run the following command to do so:

sh# sudo apt-get install ruby ruby1.8 ruby1.9 libruby1.8 libruby1.9 irb irb1.8 irb1.9 rdoc rdoc1.8 rdoc1.9 ri ri1.8 ri1.9 ruby1.8-examples ruby1.9-examples ruby1.8-elisp ruby-manual rubybook

In this case, use ‘ruby’ to execute the 1.8.4 version of the interpreter and use ‘ruby1.9′ to run the 1.9 version.

sh# ruby -v
ruby 1.8.4 (2005-12-24) [i486-linux]
sh# ruby1.9 -v
ruby 1.9.0 (2006-04-21) [i486-linux]

What about ruby-gems?

I don’t recommend installing additional Ruby packages using the ‘rubygems’ utility if you use a distribution specific package manager(apt, emerge etc) to manage the software on your system. Debain community strongly discourages its use to install the ruby packages(rightly so), as it doesn’t follow the package management conventions of Debian’s package manager(and hence can mess up with it and stop it from working properly). Same goes for Gentoo OS too. Go here to read more information on this. But if Ruby is (one of) the most important software for you, then ‘rubygems’ can make it very easy to install the latest versions of Ruby related software, long before they are added to the Debian or Gentoo repositories. In that case, follow the documentation on how to install ‘rubygems’ and how to install Ruby packages using it from this page.

In Gentoo, you can do this:

sh# emerge rubygems

Installing Ruby on Fedora/SUSE/Mandriva etc:

Use RPMs! Hunt them down using google.com or rpmfind.net and then install them one by one in the order.
Or use the package manager of each distribution(‘yum’, ‘yast’ and ‘urpmi’ respectively) and hope for the best. I have tested with yum and yast and at least they did not create too many issues for me:

Ruby on Fedora using yum:

If the yum configuration files(fedora.repo etc) are properly setup, you can install Ruby using the following command:

sh# yum install ruby.i386 ri.i386 ruby-mode.i386
sh# ruby -v
ruby 1.8.4 (2005-12-24) [i386-linux]

Above command will install ruby, irb, ri, rdoc commands and Ruby mode for Emacs. You need to add the following line to ‘.emacs’ file present in your home directory(create it otherwise) to enable Ruby mode in Emacs editor:

(require ‘ruby-mode)

On SUSE, use YaST to install ‘ruby’, ‘ruby-doc-ri’ and ‘rubygems’ packages by searching for them from the YaST interface(YaST->Software Management->Search).

sh# ruby -v
ruby 1.8.2 (2004-12-25) [i586-linux]

‘ruby’ and ‘rubygems’ are available on the SUSE 10.1 DVD itself; you can add repositories from the Internet to install the other Ruby packages(ruby-docs-ri etc), or use ‘rubygems’ to install them.
Add the following in the YaST configuration (YaST->Installation Source) if you want to install ‘ruby-docs-ri’ from the Internet:

Protocol: FTP
Server Name: ftp.mirrorservice.org
Directory on Server: /distribution/SL-10.0-OSS/inst-source/
Authentication: Anonymous

Another way would be to simply download all the needed RPM files by manually searching for them on the web and installing them directly without bothering with yast. Same can be done for Mandriva and other RPM based distributions.

Installing Ruby on Microsoft Windows:

Download the Ruby Windows installer file from the following url: Ruby 1.8.4
(blog entries become outdated very soon; this is version 1.8.4, currently the latest stable version. Always Google for the latest stable version to check if this url still useful to compensate my laziness in updating the above link once a new version is released. 40+ words waster for the lack of Package Manager in Microsoft Windows.)

Click on the installer file and follow the wizard. Once finished, you have three ways to run your Ruby programs(assuming its Windows XP):

All the menu items are available at: Start->All Programs->Ruby-184-19, so first go there.
Menu for Ruby Programs
Then,

  1. Select fxri-Interactive Ruby Help & Console menu item to load the interactive Ruby interpreter. Run your Ruby programs at the ‘irb’ prompt.

    Interactive Ruby Shell(irb) And Help

  2. Select FreeRIDE menu item, which will open a minimal IDE to write, debug and run Ruby programs.

    FreeRIDE IDE For Ruby

  3. (Recommended)Use SciTE editor.
    Select SciTE menu item. This will open the excellent editor called SciTE that supports many programming languages other than Ruby, and is also available for many other operating systems(including GNU/Linux). Its one of the best programming editors available today.

    Programmable Editor SciTE for Ruby

After finishing editing and saving the program with SciTE, go to the command prompt(Start->All Programs->Accessories->Command Prompt), change to the directory where you have saved the program and run it using the ‘ruby’ command.

C:\myprogs>ruby first.rb

End Note:

This article describes the installation of basic Ruby software. There are many related packages that can be installed to get additional functionality, like database bindings for popular database software(mysql, postgre), email support, gui programming(gtk, qt), rails, soap etc. Hopefully, I will cover installation of these packages in a future article(also planning to post an article on using various popular IDEs(Eclipse, Komodo) to create Ruby programs in Windows and GNU/Linux OS), so check back if you are interested.


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Installing C++ Boost on SuSE and Fedora
  • Installing Ubuntu & Kubuntu Dapper(6.06 LTS) For NVidia GeForce Cards
  • Killer Looks of KDE in Kubuntu Entices a Long Time GNOME User!
  • Develop Ruby Applications Using JEdit Editor
  • Installing amazon-ecs/hpricot RubyGem on Windows Operating System
  • 7-Zip Compression Format Support on GNU/Linux Using p7zip
  • Get Free GNU/Linux(Fedora, SUSE etc) CDs Delivered Anywhere Around The World

  • Readers who viewed this page, also viewed:


    5 Comments »

    1. [...] My Ubuntu Newbie Links *List of software you love on Windows/Mac that have equivalent versions in linux: here *Ubuntu Dapper Drake wiki: here *An Ubuntu Blog *Install ruby: gems or non-gems [...]

      Quote

      Pingback by Ubuntu installed — September 4, 2006 @ 12:15 pm

    2. um - i think you meant ubuntu/debian, not gentoo, in the above quote:

      In Gentoo, you can do this:
      sh# apt-get install rubygems

      Quote

      Comment by nano — March 9, 2007 @ 6:14 pm

    3. Migrating to Ruby 1.9 (YARV): Posts you have to re…

      So, you are reading everywhere that Ruby 1.9 is faster than 1.8 (even I say so! :D ) and you want to give it a try or even port your existing code to it. Where should you start from?…

      Quote

      Trackback by Nikos D. — April 21, 2008 @ 9:36 pm

    4. You write:

      In Gentoo, you can do this:
      sh# apt-get install rubygems

      apt-get in gentoo?

      Stephan

      Quote

      Comment by Stephan Wehner — September 7, 2008 @ 9:07 pm

    5. Haha, nice catch! I have corrected the post :)

      Quote

      Comment by tabrez — September 8, 2008 @ 9:32 am

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost