Reputation: 16373
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
heroku run rake db:version --remote production
but if I open a rails console
session and type in
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?
Upvotes: 0
Views: 77
Reputation: 16373
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
Bundler.with_clean_env {`heroku run rake db:version --remote production`}
Upvotes: 1