capistrano / rvm

MIT License
140 stars 47 forks source link

Bundle exec with Capistrano 3 #48

Closed benebrice closed 9 years ago

benebrice commented 10 years ago

Hello everybody,

I've read all issues posts here but nothing works for my case for the error bash: bundle: command not found I'm using Capistrano 3 with Rails 4 and Ruby 2.1.

Here is the command line that doesn't work on deploy.rb :

execute "cd #{fetch(:deploy_to)}/current/ && RAILS_ENV=#{fetch(:environment)} bundle exec rake db:migrate"

On my production.rb file, I have those settings :

set :rvm_type, :system
set :rvm_ruby_version, '2.1.1'
set :default_env, { rvm_bin_path: "/usr/local/rvm/bin" }
set :environment, "production"

Here is my Capfile

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'

require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'whenever/capistrano'

Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

This time it's my GemFile

group :development do
  gem 'capistrano', github: 'capistrano/capistrano', ref: 'master'
  gem 'capistrano-rails', github: 'capistrano/rails', ref: 'master'
  gem 'capistrano-bundler', '~> 1.1'
  gem 'capistrano-rvm', git: 'https://github.com/capistrano/rvm.git'
end

Finally the deploy logs:

DEBUG [18471155]    bash: bundle: command not found
cap aborted!
cd /mytests/test1/current/ && RAILS_ENV=production bundle exec rake db:migrate stdout: Nothing written
cd /myTests/test1/current/ && RAILS_ENV=production bundle exec rake db:migrate stderr: Nothing written
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:164:in `block (2 levels) in _execute'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:166:in `block in _execute'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/Users/Brice/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
config/deploy.rb:55:in `block (3 levels) in <top (required)>'

I would like to find a way without touching to my deploy.rb because this file is working for other stages.

Thank you in advance for your help.

mpapis commented 10 years ago

can you show how it does not work - deploy log please

benebrice commented 10 years ago

I've added that to the description of my problem. Thank you for your speed !

mpapis commented 10 years ago

I guess you should try rvm1-capistrano3 instead of capistrano-rvm ... I have even a PR for merging the two => #34

benebrice commented 10 years ago

I've just tried but it's still not working. I had to detailed my ruby version but I have the same issue. Do I need to install RVM, Ruby and GEMS directly from Capistrano even if it's already installed on my server ?

mpapis commented 10 years ago

more details please, can you show me full deploy log (you should open issue for rvm1-capistrano3 to not mess up this thread)

kirs commented 10 years ago

Did you install bundler manually on the server?

benebrice commented 10 years ago

Yes I do. But I think @mpapis has solved my problem for now. I have see more questions about this solution. I'll ask it on rvm/rvm1-capistrano3 issue#26.

mpapis commented 9 years ago

can this be closed?

benebrice commented 9 years ago

Yes it can.

mpapis commented 9 years ago

@kirs could you close?