Ruby doesnt look at local gems

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?

On Jan 12, 3:52Â pm, Larry K [email protected] 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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs