# Can't find gems in /vendor/gems/ after modifying load\_paths

**URL:** <https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279>\
**Category:** Rails\
**Created:** [February 13, 2009, 5:42pm UTC](https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279 "2009-02-13T17:42:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sackerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Post date:** [February 13, 2009, 5:42pm UTC](https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279/1 "2009-02-13T17:42:18Z")

</div>

I’m picking up a Rails app that is using a lot of older gems. We’re  
using Rails 2.0.2 and planning to move to to Rails 2.3 along with  
upgrading the the dependencies. However, in the meantime, we’re moving  
servers around and adding new folks to the dev team, so I thought it  
wise to “freeze” the gems. I’m trying to follow the methodology  
described here:

> **[Vendor Everything — err.the\_blog](http://errtheblog.com/posts/50-vendor-everything)**
>
> Err the Blog: Ruby and Rails from the front.

and here:  
[http://wiki.joyent.com/shared:kb:installing-rails](http://wiki.joyent.com/shared:kb:installing-rails)

Unfortunately, the gems don’t seem to be found.

Here’s what I did… I had all the old gems installed to ~/.gems and all  
the tests passed. Then I unpacked the gems into /vendor/gems

cd ~/rails/vendor/gems  
gem unpack exifr  
gem unpack rmagick  
gem unpack tzinfo  
gem unpack uuidtools

I added the following to config/enviroment.rb inside  
Rails::Initializer.run do |config|

config.load\_paths += Dir[“#{RAILS\_ROOT}/vendor/gems/\*\*”].map do |dir|  
File.directory?(lib = “#{dir}/lib”) ? lib : dir  
end

# print out my load\_paths for debugging

config.load\_paths.each do |p|  
puts p  
end

and later:  
require ‘rubygems’  
gem ‘exifr’, ‘=0.10.6’  
gem ‘uidtools’, ‘=1.0.2’  
gem ‘rmagick’, ‘=1.15.8’  
gem ‘tzinfo’, ‘=0.3.5’

Here’s what happens:  
$rake test:units  
(in /home/sallen/rails)  
/home/sallen/rails/test/mocks/development  
/home/sallen/rails/app/controllers/  
/home/sallen/rails/app  
/home/sallen/rails/app/models  
/home/sallen/rails/app/controllers  
/home/sallen/rails/app/helpers  
/home/sallen/rails/config  
/home/sallen/rails/lib  
/home/sallen/rails/vendor  
/home/sallen/rails/config/…/vendor/rails/railties/lib/…/builtin/rails\_info/  
/home/sallen/rails/vendor/gems/exifr-0.10.6/lib  
/home/sallen/rails/vendor/gems/tzinfo-0.3.5/lib  
/home/sallen/rails/vendor/gems/rmagick-1.15.8/lib  
/home/sallen/rails/vendor/gems/uuidtools-1.0.2/lib  
rake aborted!  
Could not find RubyGem exifr (= 0.10.6)

(See full trace by running task with --trace)  
$ ls vendor/gems/  
exifr-0.10.6 rmagick-1.15.8 tzinfo-0.3.5 uuidtools-1.0.2

I must be missing something basic. Any ideas?

Thanks in advance,  
Sarah

---

<div class="post-metadata">

**Author:** ![sackerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Post date:** [February 14, 2009, 9:10pm UTC](https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279/2 "2009-02-14T21:10:59Z")

</div>

On Feb 13, 11:42 am, Sarah A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Here’s what I did… I had all the old gems installed to ~/.gems and all
> 
> gem ‘exifr’, ‘=0.10.6’  
> gem ‘uidtools’, ‘=1.0.2’  
> gem ‘rmagick’, ‘=1.15.8’  
> gem ‘tzinfo’, ‘=0.3.5’

Take a careful look at the errtheblog article - you should be using  
require, not gem here.  
The gem statements only add the gem directories to the load\_path.

In the long run, you should definitely switch over to using  
config.gem, but that isn’t an  
option with Rails 2.0.3.

BTW, even changing to 'require’s is still going to leave you with  
problems, as RMagick’s  
native component hasn’t been built yet. I don’t know of any easy way  
to do it in your  
situation. You might want, for the short term, to just leave the ‘gem’  
lines in your environment  
and keep the gem packages for the gems you need around. That way, the  
code will complain  
loudly if the gems needed aren’t installed.

–Matt J.

---

<div class="post-metadata">

**Author:** ![sackerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Post date:** [February 14, 2009, 10:07pm UTC](https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279/3 "2009-02-14T22:07:57Z")

</div>

Matt J. wrote:

> Take a careful look at the errtheblog article - you should be using  
> require, not gem here.  
> The gem statements only add the gem directories to the load\_path.

Changing to ‘require’ got past that error. I still don’t understand why  
it failed to load since I had requires elsewhere that just didn’t  
specify the version. Where would I look up the syntax reference for  
‘gem’ and ‘require’ ? I’m not really clear where those come from. I  
see ‘require’ documented here: [http://www.rubygems.org/read/chapter/3](http://www.rubygems.org/read/chapter/3)  
but it doesn’t reference the version argument and I don’t see where  
‘gem’ is documented.

> In the long run, you should definitely switch over to using  
> config.gem, but that isn’t an  
> option with Rails 2.0.3.  
> I’ll give that a look when we upgrade.

> BTW, even changing to 'require’s is still going to leave you with  
> problems, as RMagick’s  
> native component hasn’t been built yet. I don’t know of any easy way  
> to do it in your  
> situation.  
> Thanks for the warning.

> You might want, for the short term, to just leave the ‘gem’  
> lines in your environment  
> and keep the gem packages for the gems you need around. That way, the  
> code will complain  
> loudly if the gems needed aren’t installed.  
> Hmmm… so it seems that ‘gem’ just declares that the code depends on a  
> gem, and ‘require’ actually loads the library?

Thanks so much!  
Sarah

---

<div class="post-metadata">

**Author:** ![sackerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Post date:** [February 26, 2009, 10:07pm UTC](https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279/4 "2009-02-26T22:07:50Z")

</div>

Hello everyone,

Rails 2.2.2  
Gems 1.8

When I add this to my config/environment.rb file my app fails to start.

config.load\_paths += Dir["#{RAILS\_ROOT}/vendor/gems/\*\*"].map do |dir|  
File.directory?(lib = “#{dir}/lib”) ? lib : dir  
end

Does anyone know why that might be happening?

Thank You

---

<div class="post-metadata">

**Author:** ![sackerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Post date:** [February 27, 2009, 10:22pm UTC](https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279/5 "2009-02-27T22:22:45Z")

</div>

Matt: Thank you for your reply. I have put this in the environment.rb  
file and my app fails to start?

config.gem ‘cyu-ar\_mailer’, :lib =\> ‘ar\_mailer’, :source =\>  
‘[http://gems.github.com](http://gems.github.com)’

Thanks

---

<div class="post-metadata">

**Author:** ![sackerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Post date:** [March 1, 2009, 12:21am UTC](https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279/6 "2009-03-01T00:21:18Z")

</div>

“Fails to start” is not very helpful - what error message do you get?  
It’ll be helpful to know what version of Rails you’re running, and the  
output of  
‘rake gems’. If that errors out, try ‘rake gems --trace’ to get a  
detailed error.

–Matt J.

On Feb 27, 4:22 pm, Sean M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![sackerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@sackerson](https://www.ruby-forum.com/u/sackerson)\
**Post date:** [February 27, 2009, 9:58pm UTC](https://www.ruby-forum.com/t/cant-find-gems-in-vendor-gems-after-modifying-load-paths/160279/7 "2009-02-27T21:58:22Z")

</div>

DON’T DO THAT. That’s from a very old tip that no longer applies to  
current (2.2+) versions of Rails. See this link:  
[http://api.rubyonrails.org/classes/Rails/Configuration.html#M002480](http://api.rubyonrails.org/classes/Rails/Configuration.html#M002480)

–Matt J.

On Feb 26, 4:07 pm, Sean M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
