如何解决您的Ruby版本是2.3.1,但您的Gemfile指定为2.5.1?

时间:2018-05-29 06:58:47

标签: ruby-on-rails ruby nginx passenger

您好我正在使用Phusion Passenger和NGINX来运行RoR应用程序。 但得到了这个错误 Phusion Passenger应用程序服务器尝试启动Web应用程序。但是应用程序本身(而不是Passenger)遇到了内部错误。

错误详情:

Your Ruby version is 2.3.1, but your Gemfile specified 2.5.1 (Bundler::RubyVersionMismatch)
  /var/lib/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/definition.rb:491:in `validate_ruby!'
  /var/lib/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/definition.rb:466:in `validate_runtime!'
  /var/lib/gems/2.3.0/gems/bundler-1.16.2/lib/bundler.rb:101:in `setup'
  /var/lib/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/setup.rb:20:in `<top (required)>'
  /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:363:in `activate_gem'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:221:in `block in run_load_path_setup_code'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:527:in `running_bundler'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:220:in `run_load_path_setup_code'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:91:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:380:in `run_block_and_record_step_progress'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
The stdout/stderr output of the subprocess so far is:

Error: The application encountered the following error: Your Ruby version is 2.3.1, but your Gemfile specified 2.5.1 (Bundler::RubyVersionMismatch)
    /var/lib/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/definition.rb:491:in `validate_ruby!'
    /var/lib/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/definition.rb:466:in `validate_runtime!'
    /var/lib/gems/2.3.0/gems/bundler-1.16.2/lib/bundler.rb:101:in `setup'
    /var/lib/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/setup.rb:20:in `<top (required)>'
    /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:363:in `activate_gem'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:221:in `block in run_load_path_setup_code'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:527:in `running_bundler'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:220:in `run_load_path_setup_code'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:91:in `preload_app'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:380:in `run_block_and_record_step_progress'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in `<module:App>'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'

然后我检查我安装的ruby版本。 ruby -v

ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
rbenv 1.1.1-30-gc8ba27f
Rails 5.2.0

但/ var / lib / gems目录下没有任何gem文件夹2.5.1。 只存在2.3.0文件夹。

甚至ruby版本2.5.1都没有出现在/ usr / lib / ruby​​ /目录中。目前只有2.3.0。

编辑:我也尝试更改我的Gemfile中的ruby版本但是出错了。

Your Ruby version is 2.5.1, but your Gemfile specified 2.3.1

但是,当我使用rails s应用启动时启动我的应用。

2 个答案:

答案 0 :(得分:1)

尝试使用RVM(https://rvm.io/)并安装正确版本的ruby并设置默认值。

答案 1 :(得分:0)

Gemfile中的版本更改回2.5.1,然后运行bundle install。这应该更新您的Gemfile.lock,并在需要时重新安装或更新依赖项。

之后,尝试以乘客

开始

我相信名为2.3.0的文件夹是红鲱鱼。我注意到文件夹名称似乎与ruby版本不同步,所以我会忽略它。