我有一台带有Ruby 1.9.3和rails 3.2.3的Centos6服务器。我使用RVM。然后我安装了ruby 2.0.0和rails 4.0.0。我用RVM更改了默认的ruby版本。并使用ruby --version
确认我然后相应地更改了我的 Gemfile 并根据需要运行bundle install
和/或bundle update
。一切都很好。然后我运行了service httpd restart
,然后导航到我的网站并获得以下内容:
无法启动Web应用程序(Phusion Passenger错误)
Could not find minitest-4.7.5 in any of the sources (Bundler::GemNotFound)
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:13:in `setup'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/lib/phusion_passenger/loader_shared_helpers.rb:212:in `run_load_path_setup_code'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:73:in `preload_app'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:127:in `<module:App>'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:5:in `<main>'
Environment variables
rvm_bin_path = /usr/local/rvm/bin
GEM_HOME = /usr/local/rvm/gems/ruby-1.9.3-p429
TERM = xterm
SHELL = /sbin/nologin
HISTSIZE = 1000
IRBRC = /usr/local/rvm/rubies/ruby-1.9.3-p429/.irbrc
PYTHONUNBUFFERED = 1
PASSENGER_ENV = production
PASSENGER_DEBUG_DIR = /tmp/passenger.spawn-debug.11360-47389796731312
SERVER_PORT = 80
MY_RUBY_HOME = /usr/local/rvm/rubies/ruby-1.9.3-p429
USER = nobody
REQUEST_URI = /
rvm_path = /usr/local/rvm
IN_PASSENGER = 1
RACK_ENV = production
REMOTE_PORT = 13101
rvm_prefix = /usr/local
PATH = /usr/local/rvm/gems/ruby-1.9.3-p429/bin:/usr/local/rvm/gems/ruby-1.9.3-p429@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p429/bin:/usr/local/rvm/bin:/usr/local/rvm/gems/ruby-2.0.0-p195/bin:/usr/local/rvm/gems/ruby-2.0.0-p195@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p195/bin:/usr/local/rvm/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin
MAIL = /var/spool/mail/nobody
WSGI_ENV = production
LANG = C
HISTCONTROL = ignoredups
rvm_env_string = ruby-1.9.3-p429
rvm_version = 1.20.13 (stable)
SHLVL = 2
HOME = /
RAILS_ENV = production
rvm_ruby_string = ruby-1.9.3-p429
SERVER_SOFTWARE = Apache/2.2.15 (CentOS)
LOGNAME = nobody
QUERY_STRING =
CVS_RSH = ssh
GEM_PATH = /usr/local/rvm/gems/ruby-1.9.3-p429:/usr/local/rvm/gems/ruby-1.9.3-p429@global
LESSOPEN = |/usr/bin/lesspipe.sh %s
SERVER_PROTOCOL = HTTP/1.1
REQUEST_METHOD = GET
RUBY_VERSION = ruby-1.9.3-p429
G_BROKEN_FILENAMES = 1
_ORIGINAL_GEM_PATH = /usr/local/rvm/gems/ruby-1.9.3-p429:/usr/local/rvm/gems/ruby-1.9.3-p429@global
但是在命令行中运行env
会显示以下内容:
GEM_HOME=/usr/local/rvm/gems/ruby-2.0.0-p195
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-2.0.0-p195
PATH=/usr/local/rvm/gems/ruby-2.0.0-p195/bin:/usr/local/rvm/gems/ruby-2.0.0-p195@global/bin:...and so on
GEM_PATH=/usr/local/rvm/gems/ruby-2.0.0-p195:usr/local/rvm/gems/ruby-2.0.0-p195@global
RUBY_VERSION=ruby-2.0.0-p195
我错过了什么?为什么rails试图使用错误版本的ruby?
答案 0 :(得分:5)
您需要使用目标Ruby重新编译乘客:
rvm use 2.0.0
passenger_install_apache2_module
使用它给你的输出相应地更新你的apache乘客配置。
答案 1 :(得分:3)
如果您已登录服务器
rvm --default use 2.0.0
答案 2 :(得分:2)
确定。所以在经过一些搜索之后,我发现在我的httpd.conf文件中,显式设置了旧ruby的路径。所以我改变了路径到新的红宝石路径
然后运行gem install passenger
然后用
安装它./usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.5/bin/passenger-install-apache2-module
然后service httpd restart
现在可以了!