ruby - Using rake tasks to interface with heroku -


i having issues running rake command in rails 4 app uses fileutils#sh. using rvm version manager , can't seem figure out problem. error is:

$ rake db:clone_production:to_local --trace ** invoke db:clone_production:to_local (first_time) ** execute db:clone_production:to_local heroku pgbackups:capture --expire -r production ruby version 1.9.3, gemfile specified 2.0.0 rake aborted! command failed status (18): [heroku pgbackups:capture --expire -r produ...] /users/trevor/.rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.1.0/lib/rake/file_utils.rb:54:in `block in create_shell_runner' ... more stack trace ... 

other rake tasks work such $ rake db:migrate can't seem run shell scripts. rake task looks like:

# ./lib/tasks/db.rake namespace :db   ...   namespace :clone_production     desc "clone production database local database"     task :to_local       sh "heroku pgbackups:capture --expire -r production"       file = "tmp/db/backup_#{ time.now.getutc.to_s.gsub(/ /, /_/) }.dump"       sh "curl -o #{ file } `heroku pgbackups:url -r production`"       sh "pg_restore --verbose --clean --no-acl --no-owner -h localhost -u postgres -d myapp_development #{ file }"     end   end end 

my path looks fine: /users/trevor/.rvm/gems/ruby-2.0.0-p195@myapp/bin:/users/trevor/.rvm/gems/ruby-2.0.0-p195@global/bin:/users/trevor/.rvm/rubies/ruby-2.0.0-p195/bin:/users/trevor/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/x11/bin:/usr/x11/bin:/users/trevor/workspace/adt-bundle-mac/sdk/tools:/users/trevor/workspace/adt-bundle-mac/sdk/platform-tools

i using these versions rake - 10.1.0, rails - 4.0.0, , ruby - 2.0.0-p195.

#./.ruby-version 2.0.0-p195  #./.ruby-gemset myapp 

you try run heroku command in clean environment:

bundler.with_clean_env { sh "heroku pgbackups:capture --expire -r production" } 

Comments