Question

I'm trying to execute the heroku CLI from a rake task:

  1 task :call_heroku do     
  2   `heroku pgbackups:url --remote staging`
  3 end    

bundle exec rake call_heroku returns the following output:

        /home/joe/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/bundler/
definition.rb:390:in `validate_ruby!': Your Ruby version is 1.9.3,but your 
Gemfile specified 2.1.0 (Bundler::RubyVersionMismatch)
            from /home/joe/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/
bundler.rb:116:in `setup'
            from /home/joe/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/
bundler/setup.rb:17:in `<top (required)>'
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        --remote staging

Executing heroku pgbackups:url --remote staging from the command line returns the expected URL. Do I have a problem with my rvm or heroku CLI configuration?

Environment details:

Rails 3.2.17

heroku:

joe@warpaint ~/dev/project (master) $ heroku version
heroku-toolbelt/2.39.0 (i686-linux) ruby/1.9.3

rvm:

joe@warpaint ~/dev/project (master) $ rvm version

rvm 1.25.22 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]


joe@warpaint ~/dev/project (master) $ rvm list

rvm rubies

   jruby-1.7.1 [ i386 ]
   ree-1.8.7-2012.02 [ i686 ]
   ruby-1.8.7-p374 [ i686 ]
   ruby-1.9.2-p320 [ i686 ]
   ruby-1.9.3-p0 [ i686 ]
   ruby-1.9.3-p362 [ i686 ]
   ruby-1.9.3-p392 [ i686 ]
   ruby-1.9.3-p448 [ i686 ]
   ruby-1.9.3-p484 [ i686 ]
   ruby-2.0.0-p0 [ i686 ]
 * ruby-2.0.0-p247 [ i686 ]
   ruby-2.0.0-p353 [ i686 ]
   ruby-2.0.0-p451 [ i686 ]
   ruby-2.0.0-preview2 [ i686 ]
=> ruby-2.1.0 [ i686 ]
   ruby-head [ i686 ]

# => - current
# =* - current && default
#  * - default

ruby:

joe@warpaint ~/dev/project (master) $ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]
Was it helpful?

Solution

It turns out that this is a bundler issue. Some digging around led me to this issue: https://github.com/bundler/bundler/issues/2355, which was resolved by @indirect and mentions using Bundler.with_clean_env (more on this command).

Now my task above becomes:

  1 task :call_heroku do     
  2   Bundler.with_clean_env { p `heroku pgbackups:url --remote staging` }
  3 end    

And all is well!

OTHER TIPS

it is just because you have install heroku in 1.9.3 ruby.

Install heroku in 2.1.0 ruby , it will good then.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top