0

I am trying to run rake task rake entrprise:pull on remote system from Rails application with rake task using sshkit and I am using rvm.

rake task

require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL

namespace :app do
  desc "pulls the records form remote server"
  task :pull => :environment do
    host = SSHKit::Host.new("username@ip")
    on host do |h|
      within("/home/username/my-rails-app/") do
        execute :rake, "enterprise:pull"
      end
    end
  end
end

In controller I am calling rake task as follows

def index
  %x(rake app:pull)
end

rake app:pull attempting to run rake enterprise:pull inside remote system at that time it's throwing /usr/bin/env: ruby: No such file or directory error

but when I ssh into remote system ssh username@ip and if run 'rake enterprise:pull' its working fine. my-rails-app was deployed with capistrano-3 and using rvm.

How to get rid of this problem?

CodecPM
  • 423
  • 6
  • 18
  • Check your path setup – Lars Nielsen Jul 10 '17 at 12:39
  • echo $PATH ouput: `/usr/local/rvm/gems/ruby-2.2.1/bin:/usr/local/rvm/gems/ruby-2.2.1@global/bin:/usr/local/rvm/rubies/ruby-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/rvm/bin:/home/ubuntu/.rvm/bin:/home/ubuntu/.rvm/bin` – CodecPM Jul 11 '17 at 10:57

0 Answers0