在rails网站上使用ruby退出(SystemExit)错误

时间:2014-10-17 17:51:18

标签: ruby-on-rails ruby bundler dreamhost

在dreamhost升级其服务器系统后,我的网站目前已关闭。我必须安装成功安装的bundler,当我将网站ftp到服务器时,错误编码器下降了大约100行到现在的样子。

错误代码是:

exit (SystemExit)
  /home/studioanisewm/studioanise.com/config/boot.rb:65:in `exit'
  /home/studioanisewm/studioanise.com/config/boot.rb:65:in `load_rails_gem'
  /home/studioanisewm/studioanise.com/config/boot.rb:53:in `load_initializer'
  /home/studioanisewm/studioanise.com/config/boot.rb:110:in `run'
  /home/studioanisewm/studioanise.com/config/boot.rb:11:in `boot!'
  /home/studioanisewm/studioanise.com/config/boot.rb:127
  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
  /home/studioanisewm/studioanise.com/config/environment.rb:16
  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
  /dh/passenger/helper-scripts/classic-rails-preloader.rb:96:in `preload_app'
  /dh/passenger/helper-scripts/classic-rails-preloader.rb:184
Error ID

787dc4fa

这是config / boot.rb文件

# 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 rescue nil
      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.3.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

class Rails::Boot
  def run
    load_initializer
    extend_environment
    Rails::Initializer.run(:set_load_path)
  end

  def extend_environment
    Rails::Initializer.class_eval do
      old_load = instance_method(:load_environment)
      define_method(:load_environment) do
        Bundler.require :default, Rails.env
        old_load.bind(self).call
      end
    end
  end
end

# All that for this:
Rails.boot!

1 个答案:

答案 0 :(得分:1)

从我在旧Rails分支中挖出的内容,从boot.rb file's line 65判断,你的Rails版本大约是2.1-2.2。它应该打印确切的版本号和未安装的警告。此外,版本2似乎不使用Bundler,因此您必须使用常规rubygems安装gem。尝试找出您的应用程序的确切Rails版本并运行

gem install -v 2.x.x rails

还有一个建议:您的用户不需要查看Passenger的调试信息。如果可以,请将其配置为将详细信息写入日志文件,同时向用户显示简短的错误页面。因为Passenger现在在你的页面上过于冗长。我可以通过这种行为预测各种安全问题。