Thursday, April 17, 2014

Installing Ruby (1.9.3) on my Windows 8.1

I installed Ruby on my Windows 8.1. I installed version 1.9.3 because 2.x is said to be not fully ready on Windows platform. I also installed related software packages: DevKit and an editor/IDE RubyMine.

1. REFERENCES

RubyIntaller for Windows: http://rubyinstaller.org/downloads/
WampServer:  http://www.wampserver.com/en/
Ruby on Windows Guides: http://rubyonwindowsguides.github.io/book/ch02-04.html


2. INSTALLING RUBY

I used RubyInstaller to install Ruby. I installed 1.9x because 2.x was not mature for Windows at this time.

Download RubyInstaller and DevKit from http://rubyinstaller.org/downloads/

Double click the downloaded executable (rubyinstaller-1.9.3-p545.exe) to install Ruby.

Test it in the command line terminal.
C:\>ruby --version
ruby 1.9.3p545 (2014-02-24) [i386-mingw32]
C:\>irb
irb(main):001:0> 1+2
=> 3
irb(main):002:0> exit


3. INSTALLING DEVKIT

(I downloaded a self-extracting DevKit when I downloaded RubyInstaller above. Since I am using Ruby 1.9x, rather than 2.x, I downloaded DevKit for that version.)

Install DevKit by double clicking downloaded self-extracting executable (DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe) in to my installation directory, which I decided to use "C:\DevKit".



Now run the following three programs to complete DevKit installation.
C:\DevKit>devkitvars.bat
Adding the DevKit to PATH...

C:\DevKit>ruby dk.rb init
[INFO] found RubyInstaller v1.9.3 at C:/Ruby193
Initialization complete!
Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

C:\DevKit>ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Ruby193'
[INFO] Installing 'C:/Ruby193/lib/ruby/site_ruby/devkit.rb'

Let's test.
C:\DevKit>bash
bash-3.1$ gcc --version
gcc.exe (tdm-1) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software...
bash-3.1$ exit
exit

4. INSTALL RUBY EDITOR: RUBYMINE

I installed RubyMine, a Ruby editor/IDE. It is not a free but reasonably priced. I was looking for a Ruby editor/IDE that includes a visual debugger, and RubyMine is one of few that have this feature.
First, download its latest installer from http://www.jetbrains.com/ruby/download/.
Then double click the installer (RubyMine-6.3.exe) to install.

In order to use its debugger, I also installed the following GEMs.

C:\>gem install linecache19
Fetching: linecache19-0.5.12.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed linecache19-0.5.12
1 gem installed
Installing ri documentation for linecache19-0.5.12...
Installing RDoc documentation for linecache19-0.5.12...

C:\>gem install ruby-debug-base19x --pre
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed ruby-debug-base19x-0.11.30.pre15
1 gem installed
Installing ri documentation for ruby-debug-base19x-0.11.30.pre15...
Installing RDoc documentation for ruby-debug-base19x-0.11.30.pre15...

C:\>gem install ruby-debug-ide
Fetching: ruby-debug-ide-0.4.22.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ruby-debug-ide-0.4.22
1 gem installed
Installing ri documentation for ruby-debug-ide-0.4.22...
Installing RDoc documentation for ruby-debug-ide-0.4.22...

I did a simple test. Launched Rubymine by double clicking its desktop icon. Created a project "firstproject". Created a new file "hello.rb" Then wrote a hello code as follows and ran.