Skip to content
trans edited this page Jan 6, 2013 · 4 revisions

Quick Start Guide

Install

To install, download the install shellscript and run it.

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

You may need to use sudo before the last if you are not use a Ruby version manager.

You can install via RubyGems is you want to try it out before committing to a site install. But be sure to comeback and install to a site location later if you decide to keep using it.

  gem install library

See Installation page for detailed instructions on installation.

Setup

To use Library, it needs to be added to the RUBYOPT environment variable.

Create a runtime configuration script for Bash or your particular shell environment. For example, .bash/ruby.sh with:

  export RUBYOPT="-rubylibs"
  export RUBYPATH="$(ruby -e'puts Library.sync'):$RUBYPATH"
  export PATH="$PATH:$RUBYPATH"

The first line makes sure that Library is always loaded when Ruby is run. On Ruby 1.8.x systems you might need -rubygems present as well, in which case put -rubylibs after the entry for -rubygems, but generally before anything else, e.g. export RUBYOPT="-rubygems -rubylibs".

The second line does two things. First it syncs the library cache to the current system state. Then it returns a list of of bin paths for the most recent versions of all libraries. This provides support for calling executable files on the command line. We add this to $RUBYPATH so we can use it with ruby via the -S option. Then we add that to $PATH so we can the executables via the command line itself.

Note that this approach requires that bin files in libraries be chmod +x and have the proper bang header, #!/usr/bin/env ruby. This works for most platforms, but not all. A binstubs approach is required to support all possible platforms, but this hasn't been implemented yet (volunteers welcome).

Configure

By default, Library will serve the installed gems as specified by $GEM_PATH or $GEM_HOME. You only need to adjust this if you want to serve special locations. For instance you might want Library to serve your Ruby project workspace so you can work on multiple interdependent projects simultaneously --without periodic installs or vendoring.

To adjust the configuration use the RUBY_LIBRARY environment variable.

  RUBY_LIBRARY="~/ruby-workspace:$GEM_PATH"

If you would like Library to update the cache every time Ruby is run, you can use the RUBY_LIBRARY_LIVE environment variable.

  RUBY_LIBRARY_LIVE="true"

This ensures that the locations given via RUBY_LIBRARY are always those available. However it is much slower than using the cache. So it's best used only when needed while developing.

Learn More

The above provides a brief overview of using Library. But there is more to it. To get a deeper understanding of the system and how to use it to its fullest extent, jump back up the Home page and follow detailed topic links.

That's it. Now you are ready to roll!