Why does this line break Rails with Passenger on DreamHost?

Ok, so I have a Rails application configured on DreamHost, and it worked for me a while ago, and now it is broken. I don't know much about deployment environments or anything like that, so please forgive my ignorance. In any case, it looks like the application crashes on this line in config / environment.rb:

require File.join(File.dirname(__FILE__), 'boot') 

config / boot.rb is pretty much normal, but I will include it here anyway.

 # Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails class << self def boot! unless booted? preinitialize pick_boot.run end end def booted? defined? Rails::Initializer end def pick_boot (vendor_rails? ? VendorBoot : GemBoot).new end def vendor_rails? File.exist?("#{RAILS_ROOT}/vendor/rails") end def preinitialize load(preinitializer_path) if File.exist?(preinitializer_path) end def preinitializer_path "#{RAILS_ROOT}/config/preinitializer.rb" end end class Boot def run load_initializer Rails::Initializer.run(:set_load_path) end end class VendorBoot < Boot def load_initializer require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" Rails::Initializer.run(:install_gem_spec_stubs) end end class GemBoot < Boot def load_initializer self.class.load_rubygems load_rails_gem require 'initializer' end def load_rails_gem if version = self.class.gem_version gem 'rails', version else gem 'rails' end rescue Gem::LoadError => load_error $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) exit 1 end class << self def rubygems_version Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion end def gem_version if defined? RAILS_GEM_VERSION RAILS_GEM_VERSION elsif ENV.include?('RAILS_GEM_VERSION') ENV['RAILS_GEM_VERSION'] else parse_gem_version(read_environment_rb) end end def load_rubygems require 'rubygems' min_version = '1.1.1' unless rubygems_version >= min_version $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) exit 1 end rescue LoadError $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) exit 1 end def parse_gem_version(text) $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ end private def read_environment_rb File.read("#{RAILS_ROOT}/config/environment.rb") end end end end # All that for this: Rails.boot! 

Does anyone have any ideas? I do not get any errors in the log or page.

-fREW

+4
source share
3 answers

I had the same issue on DreamHost. Frozen rails and unpacking all the gems made me pass by.

 rake rails:freeze:gems rake gems:unpack:dependencies 
+3
source

My guess was that you were breaking due to a newer version of Rails jewelry on Dreamhost. At least that was my problem when everything exploded with something like boot.rb.

Try to freeze gems from the development environment into your vendor / rails directory.

+1
source

Ya - the problem is not really in boot.rb - it's just that boot.rb is where the rails are actually loaded.

So, you will get such an error if you specify a version of Rails that simply does not exist on your Dreamhost slide. This can happen if you either upgrade your project, start a new project (and forget that you updated the rails at that time), or if you are still using the old version of the rails, and now it has been removed from the dreamhost server on.

To find out what is, take a look at config/environment.rb for a line that will read something like:

 RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION 

Then ssh to your Dreamhost server and enter gem list and see if your version is on the list.

If not, try a few options. Suppose the version you are using is 2.3.4 First, try: gem install rails -v=2.3.4 , then restart. This may be all that is required. If this does not work, try freezing and unpacking the gems (according to another answer here).

There is another possibility: you actually do not have a gem on which the rails depend, but which fails - for example, dependence on a particular version of the rack caught me once. But you may also have other gemstone addictions.

If you run rake gems , you can list all the gems that your project knows about what they need - make sure they are installed to begin with.

Then, as a kind of rude smoke test, try running script/console - if you lack an important rail harness, script/console will not load and should fail by providing you with a notification about the gem you need.

Update : If you are trying to run v 2.3.5, you may also encounter this problem: Bypassing a rack version error using Rails 2.3.5

In this case, you will need to follow the instructions.

0
source

All Articles