首页 > 解决方案 > Heroku 应用程序的 Bundler 运行的 Ruby 版本错误

问题描述

我有一个使用 Ruby 2.6.5 和 Rails 6.0.2.2 的 Rails Heroku 应用程序。这是Heroku支持的 Ruby 版本,我在 .ruby-version、我的 Gemfile 和 Gemfile.lock 中指定了它:

~ $ cat .ruby-version 
2.6.5
~ $ cat Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.5'
[...]
~ $ cat Gemfile.lock
[...]
RUBY VERSION
   ruby 2.6.5p114

但是,当我bundler env在远程应用程序上运行时,这是输出的第一部分:

~ $ bundle env
## Environment

Bundler       2.0.2
  Platforms   ruby, x86_64-linux
Ruby          2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
  Full Path   /usr/bin/ruby2.5
  Config Dir  /etc
RubyGems      2.7.6
  Gem Home    /var/lib/gems/2.5.0
  Gem Path    /app/vendor/bundle/ruby/2.6.0:
  User Path   /app/.gem/ruby/2.5.0
  Bin Dir     /usr/local/bin
Tools         
  Git         2.17.1
  RVM         not installed
  rbenv       not installed
  chruby      not installed

请注意,它使用的是 Ruby 2.5.1。这阻止了我运行 Rails 迁移,因为我总是得到错误Your Ruby version is 2.5.1, but your Gemfile specified 2.6.5。我错过了什么吗?

我尝试过的事情并没有导致行为发生任何变化:

有什么方法可以让 Bundler 使用正确版本的 Ruby?

标签: ruby-on-railsrubyherokubundler

解决方案


推荐阅读