簡體   English   中英

在應用啟動時從RVM切換到rbenv乘客預載/捆綁錯誤RubyVersionMismatch

[英]Switch from RVM to rbenv passenger preload/bundle errors on app start RubyVersionMismatch

看起來Phusion Passenger預加載器或捆綁器正在調用系統版本的kernel_require.rb,而不是rbenv版本的kernel_require.rb,並且在我啟動Rails 4.1應用程序時,捆綁器抱怨RubyVersionMismatch 這是我的本地開發箱,但我也有一個使用Apache 2.2.27(macports)進行部署的“本地”環境。

我按照說明完全刪除了RVM,按照說明安裝了rbenv,然后安裝了Ruby 2.1.2,Rails 4.1.5,Passenger,並進行了passenger-install-apache2-module 所有這些都在我的部署帳戶中完成,然后創建了一個空白測試應用程序。 當應用程序啟動時,Apache錯誤日志將報告Bundler::RubyVersionMismatch

請注意,該應用程序似乎可以正常運行。

引用rbenv ruby​​的日志行:

log:1 /path/to/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.7.2/lib/bundler/definition.rb:385:in `validate_ruby!': Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2 (Bundler::RubyVersionMismatch)
log:2 /path/to/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.7.2/lib/bundler.rb:117:in `setup'
log:3 /path/to/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.7.2/lib/bundler/setup.rb:17:in `<top (required)>'

引用Mac系統ruby的日志行:

log:4 /System/Library/Frameworks/Ruby.framework/Versions/2.0/.../ruby/2.0.0/rubygems/.../kernel_require.rb:55:in `require'
log:5 /System/Library/Frameworks/Ruby.framework/Versions/2.0/.../ruby/2.0.0/rubygems/.../kernel_require.rb:55 in `require'
log:6 Pool2/SmartSpawner.h:298: Preloader for /path/to/my/deploy/rails/testing/current started on PID 33863

環境:

OSX 10.9.4
Apache 2.2.27 installed via macports to /opt/local/apache2 etc
rbenv local 2.1.2  
rbenv global 2.1.2
rbenv which ruby /path/to/.rbenv/versions/2.1.2/bin/ruby
rbenv whence passenger 2.1.2
rails -v 4.1.5
bundler version 1.7.2
using mina v0.3.0, mina-rsync for deploy

apache的旅客配置:

LoadModule passenger_module /path/to/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
PassengerRoot /path/to/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.50
PassengerDefaultRuby /path/to/.rbenv/versions/2.1.2/bin/ruby

我沒有在部署帳戶中將rbenv local設置rbenv localglobal

  • 修復並清理:可能會導致過度殺傷
  • 從部署帳戶中刪除了rbenv:

     rm -rf ~/.rbenv 
  • 從.bash_profile中刪除了rbenv安裝程序

  • 按照說明安裝rbenv:

     git clone https://github.com/sstephenson/rbenv.git ~/.rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile $ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile 
  • 注銷/登錄

  • 將rbenv安裝程序添加到.bash_profile
  • 安裝rbenv-build:

     git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build 
  • 安裝Ruby 2.1.2和Bundler:

     rbenv install 2.1.2 gem install bundler 
  • 設置rbenv global

     rbenv global 2.1.2 gem install passenger passenger-install-apache2-module 
  • 將建議的旅客配置復制到我的本地/path/do/apache2/conf.d/passenger.conf

  • sudo apachectl restart
  • 從本地登台服務器上刪除測試應用程序:

     rm -rf /path/to/my/deploy/testing/* 

返回到開發帳戶:

  • 重新創建測試應用

     rails new .... testing 
  • cd測試

     rake db:create rake db:migrate git init git add . git commit -am 'initial' git push origin master mina -v setup server=local mina -v deploy server=local 
  • tail -f /path/to/apache2/logs/error_log

我在本地服務器上點擊了我的應用程序,並且RubyVersionMismatch不再出現在錯誤日志中,並且該應用程序正常啟動。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM