Using gems from vendor/?


#1

Maybe someone here can help me out. I’ve unpacked tzinfo in to my
vendor/ directory using “gem unpack tzinfo” and got a
vendor/tzinfo-0.1.1 directory as a result. How can I require this gem in
my app? I’m trying to use a require line in my environment.rb but no
matter what I do Rails seems to look for a locally installed copy in
/usr/local/ instead. Any advice?


#2

Kamil Kisiel wrote:

Maybe someone here can help me out. I’ve unpacked tzinfo in to my
vendor/ directory using “gem unpack tzinfo” and got a
vendor/tzinfo-0.1.1 directory as a result. How can I require this gem in
my app? I’m trying to use a require line in my environment.rb but no
matter what I do Rails seems to look for a locally installed copy in
/usr/local/ instead. Any advice?

Require isn’t working because the tzinfo.rb file in tzinfo-0.1.1/lib
doesn’t add its directory to the load path at the moment. I’ll look at
making a change to do this in a future release.

For now, you can add tzinfo-0.1.1/lib to the load path manually using
config.load_paths in environment.rb:

config.load_paths += %W( #{RAILS_ROOT}/vendor/tzinfo-0.1.1/lib )

You should then be able to require ‘tzinfo’ and have it load the copy
from vendor.

Phil


Philip R.
http://tzinfo.rubyforge.org/ – DST-aware timezone library for Ruby


#3

Philip R. wrote:

Require isn’t working because the tzinfo.rb file in tzinfo-0.1.1/lib

Phil

Thanks Philip, I’ll give this a try. Maybe you could also include this
information on the website as well? It would probably help save some
others from similar frustration :slight_smile:

Kamil