我正在使用RVM,Ruby 1.9.2,Rails 3,为Nginxconfiguration了Passenger 3.0.2,我正确设置了服务器configuration。 另一个应用程序工作至今。
但是对于新的应用程序,启动服务器时
http://myapp.local (它configuration的主机指向服务器绑定Nginx conf)它返回(Bundler :: GemNotFound)错误。 如何解决这个问题?
谢谢。
相信与否,这是大多数Rails开发者会碰到的常见问题。 看看这个帖子,详细说明我认为你正在寻找的修复。 祝你好运。 http://dalibornasevic.com/posts/21-rvm-and-passenger-setup-for-rails-2-and-rails-3-apps
有关更清晰和最新的解决方案,请查看关于使用RVM红宝石的官方文档页面。
为了它的要点,添加
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'
到你的<rails-app-path>/config/setup_load_paths.rb
。
对于基于rvm的应用程序和乘客,您可以参考这些文档:
https://rvm.io/integration/passenger http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerRuby
我特别的问题是,我没有在当前的gemset中安装乘客gem:
$ gem list --local |grep passenger # returns nothing
要安装插件和Apache模块,我已经执行了以下命令序列:
$ gem install passenger # for a specific version use the '--version' flag $ gem list --local |grep passenger passenger (4.0.18) $ passenger-install-apache2-module
安装完成后,脚本会打印说明如何在Apache配置中设置PassengerDefaultRuby变量。 瞧! – 没有额外的脚本和LOAD_PATH操作;)
我不知道为什么,但我安装了全球Gemset中缺少的宝石,它的工作原理!