我想从在我的本地MacOS开发机器上运行的shell方法检查我的生产数据库的版本。从命令行,我可以成功运行
heroku run rake db:version --remote production
但如果我打开rails console
会话并输入
hv = `heroku run rake db:version --remote production`
我看到以下错误消息:
/Users/Chris/.rvm/gems/ruby-2.5.1@golf_mentor_5.0.7/gems/bundler-1.16.1/lib/bundler/definition.rb:489:in `validate_ruby!': Your Ruby version is 1.9.3, but your Gemfile specified 2.5.1 (Bundler::RubyVersionMismatch)
from /Users/Chris/.rvm/gems/ruby-2.5.1@golf_mentor_5.0.7/gems/bundler-1.16.1/lib/bundler/definition.rb:464:in `validate_runtime!'
from /Users/Chris/.rvm/gems/ruby-2.5.1@golf_mentor_5.0.7/gems/bundler-1.16.1/lib/bundler.rb:101:in `setup'
from /Users/Chris/.rvm/gems/ruby-2.5.1@golf_mentor_5.0.7/gems/bundler-1.16.1/lib/bundler/setup.rb:20:in `<top (required)>'
from /usr/local/heroku/ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/heroku/ruby/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require
我使用的是ruby 2.5.1。 heroku --version
命令生成heroku-cli/6.16.13-dbb9c23 (darwin-x64) node-v9.11.1
。我该如何解决这个问题?
答案 0 :(得分:1)
事实证明这与此github https://github.com/bundler/bundler/issues/2489
有关。看起来捆绑包被heroku cli文件中的shebang混淆了。解决方案是为bundler
Bundler.with_clean_env {`heroku run rake db:version --remote production`}