# Ruby doesnt look at local gems

**URL:** <https://www.ruby-forum.com/t/ruby-doesnt-look-at-local-gems/181536>\
**Category:** Rails\
**Created:** [January 13, 2010, 11:55am UTC](https://www.ruby-forum.com/t/ruby-doesnt-look-at-local-gems/181536 "2010-01-13T11:55:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Larry\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@Larry\_K](https://www.ruby-forum.com/u/Larry_K)\
**Post date:** [January 13, 2010, 11:55am UTC](https://www.ruby-forum.com/t/ruby-doesnt-look-at-local-gems/181536/1 "2010-01-13T11:55:53Z")

</div>

How can I get ruby to look for gems in the local repository first,  
then in the site repository?

The following bash env vars are set and exported:

GEM\_HOME=/home5/allcarsm/ruby/gems  
GEM\_PATH=/home5/allcarsm/ruby/gems:/usr/lib/ruby/gems/1.8:/usr/lib64/  
ruby/gems/1.8

Local gems are in /home/allcarsm/ruby/gem and chronic-0.2.3 is  
installed there.

But when I run the controller which includes chronic, I get

```
    ---- uninitialized constant HomeyController::Chronic

```

I’ve been looking high and low for a config or env var to set for Ruby  
but cant seem to solve this. Help?

---

<div class="post-metadata">

**Author:** ![Larry\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@Larry\_K](https://www.ruby-forum.com/u/Larry_K)\
**Post date:** [January 14, 2010, 2:16pm UTC](https://www.ruby-forum.com/t/ruby-doesnt-look-at-local-gems/181536/2 "2010-01-14T14:16:22Z")

</div>

On Jan 12, 3:52Â pm, Larry K [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> installed there.
> 
> But when I run the controller which includes chronic, I get
> 
> Â Â Â Â ---- uninitialized constant HomeyController::Chronic

Have you included the chronic gem as a dependency in config/  
environment.rb? The error message that you’re getting tends to imply  
not.

Try this - open config/environment.rb, and add this line:

config.gem ‘chronic’

to the initializer block (you should see commented examples in the  
file already).

–Matt J.

---

<div class="post-metadata">

**Author:** ![Larry\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@Larry\_K](https://www.ruby-forum.com/u/Larry_K)\
**Post date:** [January 15, 2010, 8:30pm UTC](https://www.ruby-forum.com/t/ruby-doesnt-look-at-local-gems/181536/3 "2010-01-15T20:30:02Z")

</div>

I figured it out. The apache server doesnt start ruby using bash, so  
GEM\_HOME and GEM\_PATH were not set. These env vars are used by Ruby  
to find the gems. I figured out by reading the boot.rb code that I  
can create a file config/preinitializer.rb and set the env vars using  
Ruby language constructs. This file is included (and executed) early  
in the boot process. Now the system runs and finds the gems in the  
local repository.
