如何从ruby中检查heroku数据库版本

时间:2022-06-16 07:00:24

I want to check the version of my production database from a shell method running on my local MacOS development machine. From the command line, I can successfully run

我想从我在本地MacOS开发机器上运行的shell方法检查我的生产数据库的版本。从命令行,我可以成功运行

heroku run rake db:version --remote production

but if I open a rails console session and type in

但如果我打开一个rails控制台会话并输入

hv = `heroku run rake db:version --remote production`

I see the following error message:

我看到以下错误消息:

/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

I am using ruby 2.5.1. The heroku --version command yields heroku-cli/6.16.13-dbb9c23 (darwin-x64) node-v9.11.1. How do I fix this?

我使用的是ruby 2.5.1。 heroku --version命令产生heroku-cli / 6.16.13-dbb9c23(darwin-x64)node-v9.11.1。我该如何解决?

1 个解决方案

#1


1  

It turns out this is related to this github https://github.com/bundler/bundler/issues/2489. It looks like bundler is confused by a shebang in the heroku cli file. The solution is to use a clean environment for bundler

事实证明这与此github https://github.com/bundler/bundler/issues/2489有关。看起来捆绑器被heroku cli文件中的shebang混淆了。解决方案是为捆绑器使用干净的环境

Bundler.with_clean_env {`heroku run rake db:version --remote production`}

#1


1  

It turns out this is related to this github https://github.com/bundler/bundler/issues/2489. It looks like bundler is confused by a shebang in the heroku cli file. The solution is to use a clean environment for bundler

事实证明这与此github https://github.com/bundler/bundler/issues/2489有关。看起来捆绑器被heroku cli文件中的shebang混淆了。解决方案是为捆绑器使用干净的环境

Bundler.with_clean_env {`heroku run rake db:version --remote production`}