# :lib in config.gem

**URL:** <https://www.ruby-forum.com/t/lib-in-config-gem/177082>\
**Category:** Rails\
**Created:** [October 11, 2009, 8:11am UTC](https://www.ruby-forum.com/t/lib-in-config-gem/177082 "2009-10-11T08:11:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [October 11, 2009, 8:11am UTC](https://www.ruby-forum.com/t/lib-in-config-gem/177082/1 "2009-10-11T08:11:46Z")

</div>

Hi – I’m confused what :lib in config.gem().

When do I need it to specify?  
What should I specify? I know that I need to put the name of the  
library, but the name is always the same with the gem name?

Also do I need to add “require ‘the\_library’” when I actually use it  
somewhere in Rails? Or does the config.gem() runs “require” statement  
as well?

Sorry for the stupid questions.

- Jon

---

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [October 11, 2009, 11:55am UTC](https://www.ruby-forum.com/t/lib-in-config-gem/177082/2 "2009-10-11T11:55:57Z")

</div>

Hi Jon,

rails automatically requires a gem loaded by config.gem. how does  
rails know what to require? That’s what you specify with :lib. If you  
do not specify :lib, rails tries to require the name of the gem.

so, for example requiring the simple-navigation gem:

config.gem ‘simple-navigation’

tries to require ‘simple-navigation’, which does not work, so you have  
to specify

config.gem 'simple-navigation, :lib =\> ‘simple\_navigation’

- Andi

---

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [October 11, 2009, 12:05pm UTC](https://www.ruby-forum.com/t/lib-in-config-gem/177082/3 "2009-10-11T12:05:54Z")

</div>

Hi Jon,

Another instance where you will need to explicitly use the :lib option  
is for gems you download and install from GitHub, where gem names are  
typically prefixed with the author’s name:

> config.gem “greatseth-mediainfo”, :lib =\> ‘mediainfo’

Peter

---

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [October 29, 2009, 8:55am UTC](https://www.ruby-forum.com/t/lib-in-config-gem/177082/4 "2009-10-29T08:55:37Z")

</div>

On Sat, Oct 10, 2009 at 11:07 PM, Hunt J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Sorry for the stupid questions.

In short, if the gem name differs from the library name that one would  
require, then you’ll need to tell Rails by specifying the name of this  
library  
like

config.gem “gem-name”, :lib =\> “lib-name”

For example,

config.gem “sqlite3-ruby”, :lib =\> “sqlite3”  
config.gem “aws-s3”, :lib =\> “aws/s3”

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![Hunt\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b9e5f3/32.png) [@Hunt\_J](https://www.ruby-forum.com/u/Hunt_J)\
**Post date:** [October 29, 2009, 8:37am UTC](https://www.ruby-forum.com/t/lib-in-config-gem/177082/5 "2009-10-29T08:37:06Z")

</div>

Peter Vandenberk wrote:

> Hi Jon,
> 
> Another instance where you will need to explicitly use the :lib option  
> is for gems you download and install from GitHub, where gem names are  
> typically prefixed with the author’s name:
> 
> > config.gem “greatseth-mediainfo”, :lib =\> ‘mediainfo’
> 
> Peter

What about :lib false? I read somewhere that by using this the gem  
doesn’t actually load or something? I read this here:  
[Finally getting GetText to work with Rails 2.2 | require 'brain'](http://szeryf.wordpress.com/2009/03/07/finally-getting-gettext-to-work-with-rails-22/#comment-1013).  
Can someone explain this please?

Thanks in advance!
