Gems not loading and causing Internal Server Error

I’m running rails 2.1.2 on a hostmonster.com server where I don’t have
control over the web server for restarts. My problem is that I can
install gems, but they don’t seem to work and my app can never find them
and throws errors.

The relevant lines in my environment.rb

Rails::Initializer.run do |config|

config.gem “ezcrypto”
config.gem “acts_as_secure”

end

Now when I try to run ruby script/console I get:

Loading development environment (Rails 2.1.2)
Missing these required gems:
ezcrypto
acts_as_secure

You’re running:
ruby 1.8.6.287 at /usr/bin/ruby
rubygems 1.3.1 at /home/marlibau/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8

Run rake gems:install to install the missing gems.

I can run rake gems:install, and it produces this output:

(in /home/myuser/rails/my_app)
gem install ezcrypto
Successfully installed ezcrypto-0.7
1 gem installed
Installing ri documentation for ezcrypto-0.7…
Installing RDoc documentation for ezcrypto-0.7…
gem install acts_as_secure
Successfully installed acts_as_secure-0.0.3
1 gem installed

But then if I run ruby script/console, it throws the same error as
before.

During all this my app otherwise runs correctly except it can’t use the
gems. When the web server does restart, then my app stops working and
throws:

Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, [email protected] and
inform them of the time the error occurred, and anything you might have
done that may have caused the error.

More information about this error may be available in the server error
log.

Additionally, a 404 Not Found error was encountered while trying to use
an ErrorDocument to handle the request.
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8i DAV/2
mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server
at www.my_website.com Port 80

I have tried freezing rails / unfreezing rails, using include paths in
the environment.rb file, using “require” statements and I just have no
idea what else to do. The only thing that seems to solve it is to
remove the gems from the environment.rb file, but then I don’t get to
use them.

My plugins work fine once the server restarts so that is not an issue.

Anyone have any ideas?? Does my server just suck or is there something
I can do about this?

I have seen stuff like this before and it was environment issues…
The rake command was running from a different install of ruby than the
console/server scripts…

Did you install ruby from source and maybe you have the rpms for ruby
installed…

Hi,

I think I’m having a very similar problem as you have. I have it with
openid plugin:
http://www.ruby-forum.com/topic/170134#new

I can use the gem after setting ENV[‘GEM_PATH’] =
‘/home/mydomain/ruby/gems’

But rake is broken, I can’t migrate, or do anything with it, even
script/about complains about the gem.

I´ve spent 2 days with it with no luck.

Regards

Freddy A. wrote:

I have seen stuff like this before and it was environment issues…
The rake command was running from a different install of ruby than the
console/server scripts…

Did you install ruby from source and maybe you have the rpms for ruby
installed…

I didn’t install rails, it came pre-installed on my account under
hostmonster.com. That would explain why freezing rails doesn’t fix the
problem since I don’t believe ruby is frozen with rails. I am going to
try to install my own version of ruby and rails and see if that somehow
fixes the problem.

I did a manual install of ruby and rails following the “HOWTO: Rails 2
on hostmonster” (google it). Also, I installed my gems using the
–install-dir option:

$ gem install acts_as_secure --install-dir
/home/my_website/ruby1.8/lib/ruby/gems/1.8

Now I can use script/console with no problem. I still have a “Internal
Server Error”, but I’m hoping that goes away when they restart the web
server. I’m not sure if I could have used the --install-dir option on
the original version of ruby installed, but it’s possible that might
have fixed it too.

To get “Internal Server Error” to go away I needed to fix the shebang
line on my public/dispatch.fcgi file.