Ruby`requiret':无法加载这样的文件--fcgi Dreamhost

时间:2015-09-19 19:02:52

标签: ruby-on-rails ruby rubygems fastcgi dreamhost

尝试运行ruby脚本ruby dispatch.fcgi时出现错误

/pathtorvm/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- fcgi (LoadError)
from /pathtorvm/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from dispatch.fcgi:8:in `<main>'

我正在尝试关注Dreamhost的Rvm / Rails安装指南以及多篇博文:

Configuring Rails projects with FastCGI for Dreamhost shared hosting
RAILS 4.0.0 WITH RUBY 2.0 ON A DREAMHOST SHARED SERVER

我正在使用rvm =&gt; 1.26.11,ruby =&gt; 2.2.0,rails 4.2.2成功,甚至尝试过ruby 2.0.0。我试图将所有env_vars指向正确的位置,但我并不是100%确定$ PATH var已正确设置。

我使用bundler gem来安装我的gem并在Gemfile中有require 'fcgi'。此外,我已删除Gemfile.lock文件,并尝试再次运行bundle install。我想也许ruby-2.2.0引起了问题,但ruby-2.0.0产生了相同的结果&amp; RAILS 4.0.0 WITH RUBY 2.0 ON A DREAMHOST SHARED SERVER清楚地表明它使用ruby-2.0.0

dispatch.fcgi

#!/pathtorvm/.rvm/rubies/ruby-2.2.0/bin/ruby

# Dreamhost clears environment variables when calling dispatch.fcgi, set again
ENV['RAILS_ENV'] = 'production'
ENV['HOME'] ||= `echo ~`.strip
ENV['GEM_HOME'] = File.expand_path('~/.gems')
ENV['GEM_PATH'] = File.expand_path('~/.gems')
require 'fcgi'
require '/pathtoapplication'sfile/config/boot.rb'
require '/pathtoapplication'sfile/config/environment.rb'

class Rack::PathInfoRewriter
        def initialize(app)
                @app = app
        end

        def call(env)
                env.delete('SCRIPT_NAME')
            parts = env['REQUEST_URI'].split('?')
            env['PATH_INFO'] = parts[0]
            env['QUERY_STRING'] = parts[1].to_s
            @app.call(env)
        end
end

#Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(ApplicationNamefoundin~../config/application.rb::Application)

1 个答案:

答案 0 :(得分:0)

以上实际上根本没有帮助我。我不得不补充一点:

require 'rubygems'
Gem.clear_paths
require 'fcgi'