# Rails 2.3.2 cannot find installed gems

**URL:** <https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108>\
**Category:** Rails\
**Created:** [March 27, 2009, 11:19pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108 "2009-03-27T23:19:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [March 27, 2009, 11:19pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108/1 "2009-03-27T23:19:33Z")

</div>

I have a rails 2.3.2 application that uses crypt, RedCloth, mysql and  
openrain-action\_mailer\_tls. As long as the gems are installed in the  
@@frameworks\_gems list things work. But when gems are not loaded in  
@@frameworks\_gems, the app fails left and right with “no such file”  
errors on my gems.

I have traced into the search in gem\_path\_searcher.rb:78 and it  
appears that the comparison

```
Dir[glob].select { |f| File.file? f.untaint }

```

will never find the required gem if the gem doesn’t have a specified  
suffix.

eg:

When looking for the crypt gem (crypt-1.1.4)

glob = ‘/home/esmith/.gem/ruby/1.8/gems/crypt-1.1.4/{.}/crypt  
{,.rb,.rbw,.so,.bundle,.dll,.sl,.jar}’

so Dir[glob].select { |f| …}

generates

f = ‘/home/esmith/.gem/ruby/1.8/gems/crypt-1.1.4/./crypt’

Passing this (untainted) to File.file? fails because “crypt” is not a  
regular file.

This happens with all of the gems that are not in the @@framework\_gems  
list.

This behavior doesn’t change if they are loaded into vendor/gems. The  
only way I can get the gems to load is to have them in the central gem  
repository which I cannot access on my hosting service.

Am I missing something with this? Rails certainly appears to be.

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [March 28, 2009, 12:15am UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108/2 "2009-03-28T00:15:46Z")

</div>

On Fri, Mar 27, 2009 at 3:19 PM, Polydectes [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> appears that the comparison  
> glob = '/home/esmith/.gem/ruby/1.8/gems/crypt-1.1.4/{.}/crypt
> 
> This happens with all of the gems that are not in the @@framework\_gems  
> list.
> 
> This behavior doesn’t change if they are loaded into vendor/gems. The  
> only way I can get the gems to load is to have them in the central gem  
> repository which I cannot access on my hosting service.
> 
> Am I missing something with this? Rails certainly appears to be.

Polydectes, if you cannot access the central gem repository, then you’ll  
need to unpack the gems into vendor. Thus, you’ll have to use one of  
the following:

rake gems:unpack # unpacks the gem into  
vendor/gems  
rake gems:unpack:dependencies # unpacks the gems with their  
dependencies  
into vendor/gems

Also, their might be some gems that have native extensions after you  
perform  
the above. Thus, you  
should perform the following within the root directory of your rails  
application:

rake gems:build

Last but not least, here’s a great screen cast that talks about gems and  
their dependencies:

[http://media.railscasts.com/videos/110\_gem\_dependencies.mov](http://media.railscasts.com/videos/110_gem_dependencies.mov)

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [March 28, 2009, 6:05am UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108/3 "2009-03-28T06:05:28Z")

</div>

Conrad,

Thanks for the response.

Unfortunately, I’ve already unpacked the gems into the vendor/gems  
folder. That didn’t work for some reason.

( "This behavior doesn’t change if they are loaded into vendor/gems.  
The only way I can get the gems to load is to have them in the central  
gem repository which I cannot access on my hosting service. ")

I have been able to get the application running under Mongrel;  
however, I need to deploy on a server where they kill mongrel  
processes after 2 minutes by policy. So I need to use fcgi through  
rack to access the system.

When I test the access using dispatch.fcgi, I get a stack trace for  
each gem that cannot be found. Each of the gems that cannot be found  
is installed in my personal gem repository, and they have also been  
unpacked into my applications vendor/gems folder.

I never had problems like this with 2.1.2 or 2.2.2, but for some  
reason 2.3.2 just isn’t seeing my gems.

Eric.

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [March 28, 2009, 11:25am UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108/4 "2009-03-28T11:25:17Z")

</div>

On Sat, Mar 28, 2009 at 3:15 AM, Conrad T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > ( "This behavior doesn’t change if they are loaded into vendor/gems.  
> > is installed in my personal gem repository, and they have also been
> > 
> > > > so Dir[glob].select { |f| …}
> > > 
> > > rake gems:unpack # unpacks the gem into
> 
> Eric, after you unpacked the gems, are you requiring the gem into the  
> file(s)  
> that need it? For example,
> 
> require ‘rubygems’  
> require ‘RedCloth’

The above should be ‘redcloth’.

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [March 28, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108/5 "2009-03-28T18:33:32Z")

</div>

Can you post a stack trace? It will be a lot easier to figure out what  
the problem is…

–Matt J.

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [March 28, 2009, 11:15am UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108/6 "2009-03-28T11:15:56Z")

</div>

On Fri, Mar 27, 2009 at 10:05 PM, EMS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> gem repository which I cannot access on my hosting service. ")
> 
> > > @@frameworks\_gems list things work. But when gems are not loaded in
> > 
> > > repository which I cannot access on my hosting service.  
> > > dependencies  
> > > Last but not least, here’s a great screen cast that talks about gems and  
> > > their dependencies:
> > 
> > [http://media.railscasts.com/videos/110\_gem\_dependencies.mov](http://media.railscasts.com/videos/110_gem_dependencies.mov)
> > 
> > Good luck,
> > 
> > -Conrad

Eric, after you unpacked the gems, are you requiring the gem into the  
file(s)  
that need it? For example,

require ‘rubygems’  
require ‘RedCloth’

or

require ‘rubygems’  
require ‘crypt’

Note: In Ruby 1.9.1, one doesn’t need the following line:

```
      require 'rubygems'

```

-Conrad

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [March 29, 2009, 4:29am UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108/7 "2009-03-29T04:29:22Z")

</div>

I believe I’ve found the source of the problem.

When using a gem in Rails starting with 2.2.2, if the library name  
isn’t an exact match for the gem name, then Rails can no longer find  
the gem. Personally, I believe THIS IS A MAJOR PROBLEM WITH THE NEW  
GEMS LOADING SCHEME!!! But that’s my personal opinion. It’s as if  
the developers were taking a hint from Microsoft and taking away  
important capabilities of the system which millions of people rely on  
in an effort to make things “easier” for them. Bad Programmer! No  
Donut!!!

The solution is to configure the gems in config/environment.rb and  
include the library name. So for example, instead of just requiring  
redcloth in your class files and modules, you also need to add:

config.gem “redcloth”, :lib =\> “RedCloth”

in your environment.rb

So the fix for my problem is to find the lib names for each of the  
gems that are not being loaded. As I’ve shown above, RedCloth is the  
name for redcloth and action\_mailer\_tls in my case is in the openrain-  
action\_mailer\_tls library.

Now I just need to find the library names for crypt, rspec, and mysql.

Eric

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [March 29, 2009, 7:00am UTC](https://www.ruby-forum.com/t/rails-2-3-2-cannot-find-installed-gems/164108/8 "2009-03-29T07:00:12Z")

</div>

On Sat, Mar 28, 2009 at 7:29 PM, EMS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Donut!!!  
> So the fix for my problem is to find the lib names for each of the  
> gems that are not being loaded. As I’ve shown above, RedCloth is the  
> name for redcloth and action\_mailer\_tls in my case is in the openrain-  
> action\_mailer\_tls library.
> 
> Now I just need to find the library names for crypt, rspec, and mysql.
> 
> Eric

Yes, Brian Bates covers this in his screen cast on gem dependencies.  
I really don’t think that it’s a major issue because anything that’s  
installed  
from github has the following syntax:

\<user\_name\>-\<project\_name\>

Thus, you might find a single project that has been forked two or more  
times and the current scheme solves that problem. However, it would  
be great to install a gem from [gems.github.com](http://gems.github.com) using just the project  
name as is the case with [gems.rubyforge.org](http://gems.rubyforge.org).

Next, it would definitely be better if the gem and library name were  
identical so one wouldn’t have to hunt within the gem repository from  
the correct library name. I guess this is something that gem makers  
will have to address. Last but not least, the correct way to add the  
RedCloth gem to your application is as follows:

config.gem “RedCloth”, :lib =\> “redcloth”

Good luck,

-Conrad
