Skip to content
trans edited this page Jan 7, 2013 · 8 revisions

How to Install Library

Automatic Installation

Site installation is recommended for regular usage, as Library itself should be loaded without going through RubyGems. The easiest way to do this is to use the quick install shellscript provided in the distribution. This script should work for any Unix-based system.

    wget http://rubyworks.github.com/library/script/install-current.sh
    sh ./install-current.sh

You may need to use sudo in front of the last line in order to permit installation to the typical /usr/local/lib/site_ruby location.

Manual Installation

Understandably, some people won't feel completely comfortable with the automatic approach, and would rather handle things by hand in order to be clear about what is taking place. So lets go over the contents of the install-current.sh script. Just type these command in order to install manually.

First it saves the current directory, then makes a temporary folder to work in and switches to it.

    local dir=$(pwd)
    mkdir /tmp/library-install
    cd /tmp/library-install

Then it downloads the zip archive of the Library project and its dependencies using wget and unzip.

  wget https://github.com/rubyworks/autoload/archive/0.2.0.zip
  unzip 0.2.0.zip

  wget https://github.com/rubyworks/versus/archive/0.2.0.zip
  unzip 0.2.0.zip

  wget https://github.com/rubyworks/library/archive/0.2.0.zip
  unzip 0.2.0.zip

After that, it cds into the each directory and run the setup.rb script.

    cd autoload-0.2.0
    ruby setup.rb
    cd ..

    cd versus-0.2.0
    ruby setup.rb
    cd ..

    cd library-0.2.0
    ruby setup.rb
    cd ..

Setup.rb is an ago-old Ruby script that copies files to standard FHS-compliant locations that Ruby recognizes, e.g. /usr/local/lib/site_ruby. Again, it might be necessary to use sudo on the ruby setup.rb lines to allow access the /usr/local path --this generally depends on whether you are using a Ruby version manager that store you Rubies under a home directory or not.

Finally, it switches back to the directory it came from and removes all the temporary files it no longer needs.

    cd $dir
    rm -r /tmp/libray-install

And that's all there is to it. One thing you might want to do differently is keep the original source code around, if for no other reason that the fact that setup.rb makes a record of what files it copied to the system. In that case just use another directory instead of the temporary one.

Manual Installation via Git

A manual installation can also be performed as outlined above, but by cloning the respective repositories instead of downloading the zip archives. In some respects this a better way to go b/c it makes it easy to to update the install using a simple git pull and ruby setup.rb.

To install, either clone the Git repository and checkout the most recent tag, e.g.

    git clone http://github.com/rubyworks/library.git
    cd library
    git checkout 0.2.0
    ruby setup.rb

You will need to do this for each of the dependencies as well (versus and autoload).

Installation via RubyGems

Despite being a peer to RubyGems, Library can be install via the typical gem install invocation. This is not recommended, but as a quick way to give it a try, it should work okay.

    gem install library

When sufficiently satisfied, the gem can be uninstalled and Library installed via one of the above procedures --you know, when you are ready to roll with the big guns ;-)

Setting Up

Once Library is installed you can start using it by adding -rubylibs to your RUBYOPT environment variable, e.g. export RUBYOPT="-rubylibs". You you will want to add this to your .profile, .bashrc or equivalent configuration file, so it starts automatically in the future.

Goto [Setup] to learn more about getting Library setup for usage.