# General query about ruby libraries

**URL:** <https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321>\
**Category:** Ruby\
**Created:** [June 2, 2008, 10:28pm UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321 "2008-06-02T22:28:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sandman](https://www.ruby-forum.com/u/sandman)\
**Post date:** [June 2, 2008, 10:28pm UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321/1 "2008-06-02T22:28:19Z")

</div>

Hi all,

I would like to know where exactly to unpack external ruby libraries for  
future use. I’m using aaronp’s mechanize library (zip file)…and it  
uses the require ‘mechanize’ directive.

Thanks,  
Sandip

---

<div class="post-metadata">

**Author:** ![sandman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sandman](https://www.ruby-forum.com/u/sandman)\
**Post date:** [June 3, 2008, 6:38am UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321/2 "2008-06-03T06:38:45Z")

</div>

Sandip Gangakhedkar wrote:

> Hi all,
> 
> I would like to know where exactly to unpack external ruby libraries for  
> future use. I’m using aaronp’s mechanize library (zip file)…and it  
> uses the require ‘mechanize’ directive.
> 
> Thanks,  
> Sandip

I think the generally accepted way to install a 3rd party library is to  
use RubyGems:

“RubyGems is a standardized packaging and installation framework for  
libraries and applications, making it easy to locate, install, upgrade,  
and uninstall Ruby packages.” pickaxe2 p 215.

That’s what I do. You need to install RubyGems and learn how to use it.

---

<div class="post-metadata">

**Author:** ![sandman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sandman](https://www.ruby-forum.com/u/sandman)\
**Post date:** [June 3, 2008, 6:44am UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321/3 "2008-06-03T06:44:10Z")

</div>

On Monday 02 June 2008 23:38:02 7stud – wrote:

> Sandip Gangakhedkar wrote:

> > I’m using aaronp’s mechanize library (zip file)…and it  
> > uses the require ‘mechanize’ directive.

> I think the generally accepted way to install a 3rd party library is to  
> use RubyGems:

Just to simplify: After installing rubyGems, the command you probably  
want is:

gem install mechanize

Or, on many Unix systems:

sudo gem install mechanize

---

<div class="post-metadata">

**Author:** ![sandman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sandman](https://www.ruby-forum.com/u/sandman)\
**Post date:** [June 3, 2008, 5:45pm UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321/4 "2008-06-03T17:45:33Z")

</div>

David M. wrote:

> On Monday 02 June 2008 23:38:02 7stud – wrote:
> 
> > Sandip Gangakhedkar wrote:
> 
> > > I’m using aaronp’s mechanize library (zip file)…and it  
> > > uses the require ‘mechanize’ directive.
> 
> > I think the generally accepted way to install a 3rd party library is to  
> > use RubyGems:
> 
> Just to simplify: After installing rubyGems, the command you probably  
> want is:
> 
> gem install mechanize
> 
> Or, on many Unix systems:
> 
> sudo gem install mechanize

What about tarballs? Or zip files?  
I am aware of RubyGems. However, lots of new and recent libraries,  
especially the ones hosted on github are not yet available as gems.

Thanks,  
Sandip

---

<div class="post-metadata">

**Author:** ![sandman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sandman](https://www.ruby-forum.com/u/sandman)\
**Post date:** [June 3, 2008, 9:01pm UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321/5 "2008-06-03T21:01:49Z")

</div>

On Tuesday 03 June 2008, David M. wrote:

> On Tuesday 03 June 2008 10:44:47 Sandip Gangakhedkar wrote:
> 
> > What about tarballs? Or zip files?  
> > I am aware of RubyGems. However, lots of new and recent libraries,  
> > especially the ones hosted on github are not yet available as gems.
> 
> If a library is new enough to not be available as a gem, I’m not sure I’d  
> want to install it system-wide. You can always put it somewhere in your  
> home directory and add it to the RUBYLIB environment variable.

I wouldn’t be so categorical. There are libraries which are quite new  
and  
still, for various reasons, aren’t packaged as gems. One which comes  
immediately to my mind, because I use it, is qt-ruby, the ruby bindings  
for  
the Qt toolkit. Other are (I think) ruby-gtk2 and ruby-gnome. Then,  
there’s  
fastri, which offers both gem and tar.gz versions whose release note  
states:

RubyGems adds a noticeable overhead to fri, making it run slower than if  
you  
installed it directly from the tarball with setup.rb.

If someone is concerned about speed, he may choose to install the tar.gz  
version.

So, there may be more than one reason for which a library is not  
released as  
gems, although I wouldn’t deny that in most cases your statement is  
correct.

Stefano

---

<div class="post-metadata">

**Author:** ![sandman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sandman](https://www.ruby-forum.com/u/sandman)\
**Post date:** [June 3, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321/6 "2008-06-03T20:08:15Z")

</div>

On Tuesday 03 June 2008 10:44:47 Sandip Gangakhedkar wrote:

> What about tarballs? Or zip files?  
> I am aware of RubyGems. However, lots of new and recent libraries,  
> especially the ones hosted on github are not yet available as gems.

If a library is new enough to not be available as a gem, I’m not sure  
I’d want  
to install it system-wide. You can always put it somewhere in your home  
directory and add it to the RUBYLIB environment variable.

---

<div class="post-metadata">

**Author:** ![sandman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sandman](https://www.ruby-forum.com/u/sandman)\
**Post date:** [June 3, 2008, 5:56pm UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321/7 "2008-06-03T17:56:49Z")

</div>

On Tuesday 03 June 2008, Sandip Gangakhedkar wrote:

> What about tarballs? Or zip files?  
> I am aware of RubyGems. However, lots of new and recent libraries,  
> especially the ones hosted on github are not yet available as gems.
> 
> Thanks,  
> Sandip

To know where ruby looks for files, you can look at the contents of the  
$:  
global variable in ruby:

ruby -e ‘puts $:’

On my (gentoo linux) system, the output is:  
/usr/lib/ruby/site\_ruby/1.8  
/usr/lib/ruby/site\_ruby/1.8/i686-linux  
/usr/lib/ruby/site\_ruby  
/usr/lib/ruby/1.8  
/usr/lib/ruby/1.8/i686-linux  
.

On other systems, the output may vary. I think that the most correct  
place to  
put user-installed libraries is under the site\_ruby/1.8 directory.

An alternative could be to install them in any place you like and set  
the  
environment variable RUBYLIB to include that directory. For instance, if  
I  
decided to install some ruby libraries in /home/stefano/ruby\_libraries,  
I  
should put the line (assuming a bash shell)

export RUBYLIB=/home/stefano/ruby\_libraries

in my .bashrc file.

At any rate, unless you have very good reasons to install the library in  
a  
custom place, I think you should use the site\_ruby directory, as I said  
above.

I hope this helps

Stefano

---

<div class="post-metadata">

**Author:** ![sandman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@sandman](https://www.ruby-forum.com/u/sandman)\
**Post date:** [June 5, 2008, 6:31am UTC](https://www.ruby-forum.com/t/general-query-about-ruby-libraries/139321/8 "2008-06-05T06:31:31Z")

</div>

On Tue, Jun 3, 2008 at 11:44 AM, Sandip Gangakhedkar  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What about tarballs? Or zip files?  
> I am aware of RubyGems. However, lots of new and recent libraries,  
> especially the ones hosted on github are not yet available as gems.

Github gems are all available via rubygems so long as the package  
maintainer enables the option. See [http://gems.github.com/](http://gems.github.com/)

Do note the warning there, though. Permanently adding github as a gem  
source royally b0rked my rubygems installation. Stick with the manual  
source specification for now. E.g.

sudo gem install mojombo-grit -s [http://gems.github.com](http://gems.github.com)

–  
Avdi

Home: [http://avdi.org](http://avdi.org)  
Developer Blog: [Avdi Grimm, Code Cleric](http://avdi.org/devblog/)  
Twitter: [http://twitter.com/avdi](http://twitter.com/avdi)  
Journal: [http://avdi.livejournal.com](http://avdi.livejournal.com)
