![](/img/trans.png)
[英]Your Ruby version is 2.3.1, but your Gemfile specified 2.1.4
[英]Your Ruby version is 2.3.1, but your Gemfile specified 2.3.1 (same version)
所以我遇到了以下问题:
Your Ruby version is 2.3.1, but your Gemfile specified 2.3.1
当我部署我的应用程序时说Heroku。 仅当您与当前的ruby版本和Gemfile的ruby版本不匹配时,才会发生此错误。
您可以在这里看到任何代码
这是构建输出:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.1
remote: -----> Installing dependencies using bundler 1.11.2
remote: Ruby version change detected. Clearing bundler cache.
remote: Old: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
remote: New: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote: Your Ruby version is 2.3.1, but your Gemfile specified 2.3.1
remote: Bundler Output: Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote: Your Ruby version is 2.3.1, but your Gemfile specified 2.3.1
remote: !
remote: ! Failed to install gems via Bundler.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to chatisto.
remote:
是什么导致此错误?
woooooow,讨厌的失败。 😂
发现问题:
我从.ruby-version
读取了ruby版本,因为在执行rbenv local 2.3.1
时rbenv会生成此文件。 该文件在版本号之后中断。 ( 在这里修复)
我使用以下代码来阅读它:
ruby_version_file = File.expand_path(".ruby-version", __dir__)
ruby File.read(ruby_version_file)
虽然File.read(ruby_version_file)
返回"2.3.1\\n"
...但是在heroku构建日志中,这确实很难看到。
在Jenkins构建自动化中,我遇到了完全相同的错误,但是在不同的上下文中。 就我而言,解决方案是调用:
rbenv rehash
调用现有代码行后: rbenv local 2.3.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.