Install Ruby  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews Ruby
Written by Bogdan V   
Tuesday, 23 January 2007

Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable.

In this article you will learn how to install ruby on Windows, Mac Os X and Linux. Sometimes if you have try it to install  GNU compiler on a windows is kind of a big pain and a lot of work, but ruby is quite very easy and simple to install it on the most platforms.


Install Ruby on Windows.
  
Installing ruby on windows is quite a snap, just go on http://www.ruby-lang.org and click on Ruby link under the Download side bar. Click on the install Ruby under Windows link, on that page you will find the installer that you need to run it under windows ( in the end you just need to download it, run it and your are finish, also read the instruction before to start installing Ruby ).

installrubywindows To edit Ruby files, simply you need to use a text editor. For a start you can use Notepad editor from windows or if you fancy to work with others editors you can try UltraEdit, also ruby comes with a fine editor named SciTE which will properly highlight, open, and save Ruby files for you; also has a nice feature to help you run your ruby programs without running all the time in the command line to get them going.

There are other Ruby specific development environments ( e.g FreeRIDE, Arachno, Mondrian, etc.), but these environments are not necessary to do development (i.e depends on you if you want to use them)

If you decide to use Notepad or something that doesn’t have a feature that allows you to run your application from with it, then you need to find your programs using the command line and add the Ruby command  line like in this example:

ruby mycodefile.rb

Is better to use SciTE to avoid this matter, but sometimes this is necessary specially if you are comfortable with others editors.

Install Ruby on Mac OS X

Now after you have read it on how to install Ruby on Windows, we will continue to show you how to install ruby on Mac OS X.

If your system is on Jaguar 10.2 or later, then you should have a version of ruby install it on your system, to find what version of ruby is install it on your system just simple type this command: 

ruby –v

That should give you a short message which is telling you what type of ruby version do you have install it on your system . Make sure that your version is compatible with this article, which basically is based on 1.8 versions. If you don’t have one then lets start installing one.

One of the easiest way to install ruby on your system is by going to use DarwinPorts (http://www.darwinports.org). Go to their download page and pick up the right .dmg file for your system, for example if you using Tiger 10.4 then you would downloading something like DarwinPorts-1.2-10.4.dmg. After you have download it, just install it as normally. Open terminal and enter the following command:

sudo port sync
sudo port install ruby

After you have type those commands you will see how it will download some files, it will compile some things, It will calculate the airspeed velocity of an unladen swallow, and in the end you will have a nice working Ruby distribution install it on your system.

Make sure to run ruby –v command to see if everything is in order with your installation. If that command will not work then try use the Darwin support web site, mailing list and also if you have problems with this article use WEB DOT DEV forum board.

macinstallruby As we was talking on windows on how to edit the files in mac is quite very easy to edit the files. They can be edit with a text editor like Text for something very simple, but if you want that your things to be a bit more out of your environment, you can use something like Text Mate (something which I recommend), BBEdit, TextWrangler, SubEthaEdit, and many more.
 
If you are Unix user you can use emacs, works perfectly fine and a lot of work has been done with these editors to actually make them pretty usable Ruby development environments if you are so inclined to use them.

Install Ruby on Linux

Now the last step, on how to install ruby on linux. First to see if you have ruby install it or not on your system you need to type ruby –v in the command line, is  the same command like I have told you on mac.

Again if you are having problems not finding ruby install it on your system then prepare it to install it.

Fortunately, Ruby has a good support on Linux systems, always depending on your system/ environment, you will have to do one of the following.

Install from Administrator

If you are not the administrator of the system then you may have a small problem with your administrator and you may throw yourself at the mercy of your administrator. Tell him or her to install it for your, do what ever takes you to make him or her to install it for you. In the end what ever takes you try to get Ruby install it.


Now lest try to install ruby from package. Before you start to install ruby you need to consult your distribution’s documentation. Each of the linux system handle these sorts of things differently, but in the end if your system doesn’t have a package you still have options.
 
Check unofficial repositories such as Dag’s, Minds’s, Shadoi’s or Debian Unofficial.

Install ruby from source is something which people think from the first time. You get a smidge better performance, for sure, I like to get the things done much quickly as possible. So I’d rather use a package instead of using a installation for a source file. In the end if you cannot find a package you can still install it from a source file.
 
First step is to go on http://www.ruby-lang.org and download the source archive file. Extract it and enter the source directory:

tar zxvf ruby-1.8.5.taz.gz
cd ruby-1.8.5

Have a look inside the directory for a bit, you might want to read the license or README file so to make sure that there aren’t any gotchas for your distribution of Linux.  In the end you need to configure, build,  and install it. Type the commands from the bellow example:

./configure
make
make install

Your should be good at this point, now if everything is ok type ruby –v to see if what you have install it, it has been install it properly.

For editing Ruby file on Linux is very simple by using a plain text editor like gEDIT or your favorite console editor, such as vi, emacs or nano. Or one of the X Windows counterparts like xemacs.

Lets try Ruby

Let’s give this whole Ruby thing a try. You can use irb or fxri to get a instant feedback or type the source code in a file and use Ruby to execute it. If you still want to use the former, type irb on the command line or find fxri in the program group for Ruby. If you want to simply type it and execute it, open your editor and let’s get starting.

puts “Hello, world.”

This is, of course the first example which is been used in all most all of the articles or books related to programming. Your should seen “Hello, world.” If you’re saving this file as something like hello.rb and then type in the command link hello.rd to execute it.

Lets make this more interesting with a bit of action.

Puts “Hello, world. What is your name?”
Myname = gets()
Puts “Well, hello there “ + myname + “.”

Save again the file and run this: you should see a greeting, asked for your name, and then greeted by the name. If you didn’t figure out, puts makes text come up on the console and gets gets text from the user.


Conclusion.


In this article you have learned on how to install Ruby on every platforms which ruby support them and a little bit of ruby.
 


User reviews

There are no user reviews for this item.

Add new review




Powered by jReviews

Last Updated ( Wednesday, 13 February 2008 )
 
< Prev   Next >