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.
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.
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.
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.