capistrano / rbenv

Idiomatic rbenv support for Capistrano 3.x
MIT License
203 stars 60 forks source link

Could not locate Gemfile #55

Closed brenoperucchi closed 9 years ago

brenoperucchi commented 9 years ago

Using rbenv gem 'capistrano', '~> 3.4.0' gem 'capistrano-rails', '~> 1.1.3' gem 'capistrano-bundler', '~> 1.1.4' gem 'capistrano-rbenv', '~> 2.0.3'

set :rbenv_type, :user # or :system, depends on your rbenv setup set :rbenv_ruby, "2.2.0" set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" set :rbenv_map_bins, %w{rake gem bundle ruby rails} set :rbenv_roles, :all # default value

When I try execute mailman_daemon with capistrano I have this error. I'm with this for two days. The command "bundle exec mailman_daemon start" works on console

namespace :mailman do  
  desc "Mailman::Start"
  task :start do 
    on roles(:app) do
      with rails_env: fetch(:rails_env) do
        execute :bundle, :exec, :'script/mailman_daemon start', :args=> :start
      end
    end
    # on roles(:app) do
    #   execute "cd #{current_path}&& bundle exec script/mailman_daemon start", raise_on_non_zero_exit: false
    # end
  end
$ cap mailman:start
DEBUG[23824710] Running /usr/bin/env [ -d ~/.rbenv/versions/2.2.0 ] on gestor.imentore.com.br
DEBUG[23824710] Command: [ -d ~/.rbenv/versions/2.2.0 ] 
DEBUG[23824710] Finished in 2.018 seconds with exit status 0 (successful).
INFO[4a2f3d68] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.0 ~/.rbenv/bin/rbenv exec                          
bundle exec script/mailman_daemon start on gestor.imentore.com.br
DEBUG[4a2f3d68] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.0 RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.0 ~/.rbenv/bin/rbenv exec bundle exec script/mailman_daemon start )
DEBUG[4a2f3d68]     [31mCould not locate Gemfile[0
blackjid commented 9 years ago

what if you add a within current_path do method?

task :start do 
    on roles(:app) do
        within current_path do
            with rails_env: fetch(:rails_env) do
              execute :bundle, :exec, :'script/mailman_daemon start', :args=> :start
            end
        end
    end
end
brenoperucchi commented 9 years ago

Because I saw others mailman examples with this syntax. I tried to seek more information about this but I not found.

blackjid commented 9 years ago

but you are not telling the task where to run it... the part that is commented in fact does a cd before running bundle, that should work. But the within directive does exactly that, prepends the cd command to the execute command

brenoperucchi commented 9 years ago

If I running the second part was commented the show me the bundle not found

on roles(:app) do
  with rails_env: fetch(:rails_env) do
    # execute :bundle, :exec, :'script/mailman_daemon start'
     execute "cd #{fetch(:deploy_to)}/current/; RAILS_ENV=#{fetch(:environment)} bundle exec script/mailman_daemon start", raise_on_non_zero_exit: false
   end
end
$ cap mailman:start
DEBUG[bb9e603e] Running /usr/bin/env [ -d ~/.rbenv/versions/2.2.0 ] on gestor.imentore.com.br
DEBUG[bb9e603e] Command: [ -d ~/.rbenv/versions/2.2.0 ]
DEBUG[bb9e603e] Finished in 2.004 seconds with exit status 0 (successful).
INFO[239b7946] Running /usr/bin/env cd /home/app/current/; RAILS_ENV= bundle exec script/mailman_daemon start on gestor.imentore.com.br
DEBUG[239b7946] Command: cd /home/app/current/; RAILS_ENV= bundle exec script/mailman_daemon start
INFO[239b7946] Finished in 0.302 seconds with exit status 127 (failed).
DEBUG[239b7946]     bash: bundle: command not found
INFO[239b7946] Finished in 0.302 seconds with exit status 127 (failed).
brenoperucchi at new-host-5 in ~/Google Drive/03 - Apps/gestor on master*
blackjid commented 9 years ago

that is because you are passing the bundle command as a string, you need to pass it as a symbol in order for sshkit to be able to use the mapped bundle command.. (sshkit would call bundle with the absolute path)

Have you tried using the within directive I mention earlier?? just wrap the with_env directive with within current_path do for what I see it should work.

brenoperucchi commented 9 years ago

I updated my last comment with the last code I used. Could you write the syntax that you mentioned?

blackjid commented 9 years ago

It is in the first comment I made...here it is again

task :start do 
    on roles(:app) do
        within current_path do
            with rails_env: fetch(:rails_env) do
              execute :bundle, :exec, :'script/mailman_daemon start', :args=> :start
            end
        end
    end
end
brenoperucchi commented 9 years ago

thanks so much!

blackjid commented 9 years ago

:+1: