2013-07-01 39 views
1

我有一個Centos6服務器與Ruby 1.9.3和軌道3.2.3上。我使用RVM。然後我安裝了ruby 2.0.0和rails 4.0.0。我用RVM改變了默認的ruby版本。與ruby --version證實然後我改變了我的的Gemfile適當,並根據需要跑bundle install和/或bundle update。一切都很好。然後我跑service httpd restart其工作,然後導航到我的網站,並得到如下:爲什麼Rails使用錯誤版本的Ruby?

Web應用程序無法啓動(的Phusion客運錯誤)

Could not find minitest-4.7.5 in any of the sources (Bundler::GemNotFound) 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/runtime.rb:13:in `setup' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup' 
/usr/local/rvm/gems/[email protected]/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/[email protected]/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/[email protected]/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/[email protected] 
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/[email protected] 

但在命令行中運行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/[email protected]/bin:...and so on 
GEM_PATH=/usr/local/rvm/gems/ruby-2.0.0-p195:usr/local/rvm/gems/[email protected] 
RUBY_VERSION=ruby-2.0.0-p195 

我錯過了什麼?爲什麼rails試圖使用錯誤版本的ruby?

+0

這是你的Apache配置文件? – simonmorley

+0

不。這是Phusion Passenger錯誤的輸出。 – SnareChops

+0

不這麼認爲。多年來沒有使用過乘客,但是您可以使用類似PassengerRuby /meh/.rvm/wrappers/ruby-2.xxx/ruby的設置。可能會離開。 – simonmorley

回答

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安裝了它,現在它的作品!

3

如果你登錄到你的服務器運行

rvm --default use 2.0.0 
+0

我已經做到了,但理智的緣故。我再次運行該程序,重新啓動apache,結果仍然相同。是否有一些配置告訴rails使用其他版本的ruby?它會有幫助,我將如何刪除1.9.3版本的紅寶石? – SnareChops

+0

如果你真的使用Ruby的RVM版本再次嘗試上面的代碼,因爲我離開了一個0。而且運行上面運行的代碼,其紅寶石看後 – coletrain

5

你需要重新編譯乘客與你的目標紅寶石:相應地與輸出

rvm use 2.0.0 
passenger_install_apache2_module 

更新你的apache乘客CONFIGS它給您。

相關問題