When trying to run a ruby script ruby dispatch.fcgi
I get the error
/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>'
I am trying to follow Dreamhost's Rvm/Rails install guide as well as multiple blog posts:
Configuring Rails projects with FastCGI for Dreamhost shared hosting
RAILS 4.0.0 WITH RUBY 2.0 ON A DREAMHOST SHARED SERVER
I am using rvm => 1.26.11, ruby => 2.2.0, rails 4.2.2 successfully and have even tried ruby 2.0.0. I have tried to point all of my env_vars to the proper place but I am not 100% sure the $PATH var is setup properly.
I am using the bundler gem to install my gems and have require 'fcgi'
inside of the Gemfile. Also I have removed the Gemfile.lock file and tried to run bundle install again. I thought maybe ruby-2.2.0 is causing problems but ruby-2.0.0 produced the same result & RAILS 4.0.0 WITH RUBY 2.0 ON A DREAMHOST SHARED SERVER clearly shows it working with 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)
The reason is because I am using rvm. In dispatch.fcgi
ENV['GEM_HOME'] = File.expand_path('~/.gems')
ENV['GEM_PATH'] = File.expand_path('~/.gems')
should be instead (notice /gems/ not /.gems/ -it will default to Dreamhost's ruby instead of my custom install)
ENV['GEM_HOME'] = File.expand_path('~/.rvm/gems/ruby-2.2.0')
ENV['GEM_PATH'] = File.expand_path('~/.rvm/gems/ruby-2.2.0')
Thanks Dreamhost for the help