capistrano / rvm

MIT License
140 stars 47 forks source link

Trying to bundle exec sidekiqctl/sidekiq, it says bundle command not found... #43

Closed Altonymous closed 10 years ago

Altonymous commented 10 years ago

At first I tried to just use bundle exec sidekiqctl but since all my other commands seem to need to run in the app's current directory I wrapped my execute within current_path do ... end

It ends up trying to execute cd /var/app/current && bundle exec sidekiqctl stop /var/app/shared/tmp/pids/sidekiq.pid

Which works when I copy and paste that on the server logged in as the deploy user.

However, when it runs during capistrano deployment it fails... bash: bundle: command not found

Here's my restart task code...

namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      within current_path do
        if test("[ -f #{shared_path.join('tmp/pids/sidekiq.pid')} ]")
          execute :sidekiqctl, "stop #{shared_path.join('tmp/pids/sidekiq.pid')}" 
        end

        execute :sidekiq, '-r ./main.rb -e development -C ./config/sidekiq.yml -d'
      end
    end
  end

Maybe I'm posting to the wrong repo.. but I have a feeling this has something to do with how my RVM is configured.

I have this in my ~/.bash_profile

$ cat ~/.bash_profile

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
mpapis commented 10 years ago

do you tried with capistrano/bundler for bundle exec version?

Altonymous commented 10 years ago

Yeah.. I ended up having to add

SSHKit.config.command_map[:sidekiq] = "source ~/.bash_profile && bundle exec sidekiq"
SSHKit.config.command_map[:sidekiqctl] = "source ~/.bash_profile && bundle exec sidekiqctl"

to my deploy.rb file.

mpapis commented 10 years ago

please check https://github.com/capistrano/rvm/blob/master/lib/capistrano/tasks/rvm.rake#L37-L40 for better solution

kirs commented 10 years ago

bundle exec is being added only to the commands listed in bundle_bins.

Here is the solution:

set :bundle_bins, fetch(:bundle_bins, []).push %w(sidekiq sidekiqctl)
OscarBarrett commented 10 years ago

@kirs I think you mean rvm_map_bins. The OPs command is already prefixed with bundle exec.

Using bundle_bins by itself doesn't seem to prefix the rvm path/verson when executing a bundled binary.

kirs commented 10 years ago

@OscarBarrett yeah, sorry for the mistake. You can also use both of them, depends what behaviour exactly do you need.