开发者

RVM, Ruby 1.9.2, Rails 3, Passenger 3.0.2 (Bundler::GemNotFound)

I'm using RVM, Ruby 1.9.2, Rails 3, Passenger 3.0.2 configured for Nginx, I setup server configuration correctly. Another app working so 开发者_如何学Pythonfar.

But for the new app, when booting server

http://myapp.local (its configured with hosts to point server bind on Nginx conf) It returns (Bundler::GemNotFound) error. How to get around this?

Thanks.


Believe it or not this is a very common problem most Rails Developers will come across. Have a look at this post which details the fix I think you are looking for. Best of luck. http://dalibornasevic.com/posts/21-rvm-and-passenger-setup-for-rails-2-and-rails-3-apps


For a clearer and up to date solution, check out the official docs page on using RVM rubies with Passenger.

For the gist of it, add

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    gems_path = ENV['MY_RUBY_HOME'].split(/@/)[0].sub(/rubies/,'gems')
    ENV['GEM_PATH'] = "#{gems_path}:#{gems_path}@global"
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    raise "RVM gem is currently unavailable."
  end
end

# If you're not using Bundler at all, remove lines bellow
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'

to your <rails-app-path>/config/setup_load_paths.rb.


For rvm based apps and Passenger, you may refer to these docs:

https://rvm.io/integration/passenger http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerRuby

My particular problem was that I didn't have the passenger gem installed in the current gemset:

$ gem list --local |grep passenger # returns nothing

To install the plugin and the Apache module, I've executed the following sequence of commands:

$ gem install passenger # for a specific version use the '--version' flag
$ gem list --local |grep passenger
passenger (4.0.18)
$ passenger-install-apache2-module

After the installation the script printed instructions how to set the PassengerDefaultRuby variable in Apache's config. Voilà! - no extra scripts and LOAD_PATH manipulation ;)


I don't know why, but I installed the missing Gem in Global Gemset and it works!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜