Un Ltd. web logs by this guy!

Tutorial: Setting up a Ruby environment from scratch

2016-04-06

   

Ruby Setup

Disclaimer:
This tutorial is intended for Windows users.
All commands are intended to be run in your command prompt
ie:

cmd.exe

Direct Installers

Downloads Archive of all installer files for your desired Ruby version (prefer the latest one x86 version to be on the safe side, x64 may not always be compatible with all gems and dependencies, I have been burnt with DB OCI dependencies)…

(If you are unsure, I recommend the RailsInstaller as a default installer package if you have admin access to your machine)

Non-MSI Install steps

  1. UnZip the 7z file from the Downloads Archive, and extract it to
     C:\ruby2XY # for Ruby 2.X.Y
    

    e.g.: C:\ruby223

More Installs

DevKit is a package that can be used for compiling some Linux based object files

  1. Run
      ruby dk.rb init
    
  2. Open the newly created Config.yml file and add your version of Ruby:
      ---
      - C:/ruby233
    
  3. Run
      ruby dk.rb install
    

Oracle InstantClient for querying Oracle DBs It can be a bit tricky to get this downloaded properly..

  1. Download the 32-bit version of instantclient (zip file) from this Oracle link
    1. You need the OCI.dll file to query Oracle DBs, so download the zip that suits you.
    2. You may have to jump through some hoops and register with your email id.
  2. Unzip this file and add its contents to

    C:\Instantclient_12_1;

ENV Variable Changes

  1. add the bin directory to your env path

    Start > env

    env.png

  2. Add (using Edit)/Set (using New) the following variables for

    Note: If your system Variable name is not found, you create a new one instead of editing it.

    env_vars.png

These are the expected ENV variables

PATH => C:\ruby233\bin;C:\DevKit;C:\Instantclient_12_1; # Caution: semi-colons are very important;
TNS_ADMIN => C:\Instantclient_12_1 # ie: the location that contains the tnsnames.ora file

Ensure you are good so far

Run the following commands to check that your setups

ruby -v
# ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32] # sample output

Gems setup

If you are from a Java background, here is a simple intro to Ruby lingo

Ruby vs Java
gem <=> JAR
gemfile <=> equivalent to the POM.xml file with Maven (Java)

There is a gem called bundler that helps with package management like Maven
(roughly, but maven does a lot more than bundler.. its like bundler, rake, rails scaffolder etc combined!)..
Here is a good wiki that gives you a comparison of the bundler and maven

Install Bundler

  • make sure you can access ruby from your terminal (hit WinKey + R and run ruby -v on your terminal)
  • make sure you are proxy is set (see the Proxy Setup section below)
  • then run
    gem install bundler
    

Proxy Setup

If your DNS is behind a firewall and you need to proxy your way out
for example:

set http_proxy=http://proxy.your_org_domain.net:8443/

This sets up your http_proxy env config that lets you access the rubygems gem-host server for installing gems.

bundle install

bundler is the most widely used package manager for Ruby.. just run bundle install to install all your dependencies..

cd <your Project directory that has your 'gemfile'>
bundle install

Ruby IDEs

An IDE that most Rubyists prefer is RubyMine But you also have so many other options Light Editors

  1. Sublime Text
  2. Notepad ++
  3. Vim spf-13

More Robust Editors

  1. Aptana RadRails
  2. Net Beans + Ruby
  3. Eclipse with Ruby plugin on DLTK

RubyMine

Easy to work with and widely preferred IDE from JetBrains. This was what I had the least hassle with and found most comfortable to work with and hence recommend the same…



Comments

Content