rails que deploy commands capristano ruby-on-rails-4 gem capistrano3

ruby on rails 4 - deploy - RVM, Capistrano 3 y el paquete falla



github capistrano (1)

¿Has oído hablar de rvm1-capistrano3 ?

Esto se instala poniendo en Gemfile

gem ''rvm1-capistrano3'', :require => false

(no olvide instalar paquete) y poner en Capfile

require ''rvm1/capistrano3''

Esto resolvió mis problemas de una vez.

Mientras modificas el Capfile debes eliminar (o comentar)

require ''capistrano/rvm''

ya que esto no es necesario con esta joya y puede romper cosas.

Estoy usando Capistrano 3:

➜ webapp git:(rails) ✗ cap --version Capistrano Version: 3.1.0 (Rake Version: 10.1.1)

Mi Capfile es:

# Load DSL and Setup Up Stages require ''capistrano/setup'' # Includes default deployment tasks require ''capistrano/deploy'' require ''capistrano/rails'' require ''capistrano/rvm'' require ''capistrano/bundler'' require ''capistrano/rails/assets'' require ''capistrano/rails/migrations'' # Loads custom tasks from `lib/capistrano/tasks'' if you have any defined. Dir.glob(''lib/capistrano/tasks/*.cap'').each { |r| import r }

Y mi deploy.rb es:

set :rvm_type, :user set :application, "my_app" set :scm, :git set :repo_url, ''[email protected]:nanounanue/my_app.git'' set :scm_passphrase, "" set :ssh_options, {:forward_agent => true} set :default_run_options, {:pty => true} set :stages, ["vagrant"] set :default_stage, "vagrant" namespace :deploy do task :start do ; end task :stop do ; end desc ''Restart application'' task :restart do on roles(:app), in: :sequence, wait: 5 do run "sudo touch #{File.join(current_path,''tmp'',''restart.txt'')}" end end after :publishing, :restart after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do # Here we can do anything such as: # within release_path do # execute :rake, ''cache:clear'' # end end end end

Como puede ver, estoy intentando implementar en una Vagrant VM .

El problema es que cuando ejecuto (cualquier) comando de Capistrano ocurre lo siguiente:

➜ webapp git:(rails) ✗ cap vagrant deploy --trace ** Invoke vagrant (first_time) ** Execute vagrant ** Invoke load:defaults (first_time) ** Execute load:defaults ** Invoke bundler:map_bins (first_time) ** Execute bundler:map_bins ** Invoke rvm:hook (first_time) ** Execute rvm:hook ** Invoke rvm:check (first_time) ** Execute rvm:check DEBUG [501eda1d] Running ~/.rvm/bin/rvm version on 192.168.33.10 DEBUG [501eda1d] Command: ~/.rvm/bin/rvm version DEBUG [501eda1d] DEBUG [501eda1d] rvm 1.25.20 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] DEBUG [501eda1d] DEBUG [501eda1d] Finished in 0.446 seconds with exit status 0 (successful). rvm 1.25.20 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/] DEBUG [c7fc23f0] Running ~/.rvm/bin/rvm current on 192.168.33.10 DEBUG [c7fc23f0] Command: ~/.rvm/bin/rvm current DEBUG [c7fc23f0] ruby-2.0.0-p247 DEBUG [c7fc23f0] Finished in 0.185 seconds with exit status 0 (successful). ruby-2.0.0-p247 DEBUG [3fb3aad9] Running ~/.rvm/bin/rvm default do ruby --version on 192.168.33.10 DEBUG [3fb3aad9] Command: ~/.rvm/bin/rvm default do ruby --version DEBUG [3fb3aad9] RVM is not a function, selecting rubies with ''rvm use ...'' will not work. DEBUG [3fb3aad9] DEBUG [3fb3aad9] You need to change your terminal emulator preferences to allow login shell. DEBUG [3fb3aad9] Sometimes it is required to use `/bin/bash --login` as the command. DEBUG [3fb3aad9] Please visit https://rvm.io/integration/gnome-terminal/ for a example. DEBUG [3fb3aad9] DEBUG [3fb3aad9] ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] DEBUG [3fb3aad9] DEBUG [3fb3aad9] Finished in 0.309 seconds with exit status 0 (successful). ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

Esto continúa y cuando llega a la parte de bundle install del bundle install :

DEBUG [184656ed] Command: cd /home/vagrant/apps/releases/20140313235436 && ~/.rvm/bin/rvm default do bundle install --binstubs /home/vagrant/apps/shared/bin --path /home/vagrant/apps/shared/bundle --without development test --deployment --quiet DEBUG [184656ed] RVM is not a function, selecting rubies with ''rvm use ...'' will not work. DEBUG [184656ed] DEBUG [184656ed] You need to change your terminal emulator preferences to allow login shell. DEBUG [184656ed] Sometimes it is required to use `/bin/bash --login` as the command. DEBUG [184656ed] Please visit https://rvm.io/integration/gnome-terminal/ for a example. DEBUG [184656ed] DEBUG [184656ed] You are trying to install in deployment mode after changing DEBUG [184656ed] your Gemfile. Run `bundle install` elsewhere and add the DEBUG [184656ed] updated Gemfile.lock to version control. DEBUG [184656ed] DEBUG [184656ed] You have added to the Gemfile: DEBUG [184656ed] * crossfilter-rails DEBUG [184656ed] cap aborted! bundle stdout: Nothing written bundle stderr: Nothing written /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `call'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `do_request'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:561:in `channel_request'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:269:in `wait'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:164:in `block (2 levels) in _execute'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `call'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:166:in `block in _execute'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:30:in `block (5 levels) in <top (required)>'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:89:in `with'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:22:in `block (4 levels) in <top (required)>'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:81:in `within'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:21:in `block (3 levels) in <top (required)>'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'' /home/nano/.rvm/gems/ruby-2.0.0-p247@opi-webapp/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'' Tasks: TOP => deploy:updated => bundler:install The deploy has failed with an error: #<SSHKit::Command::Failed: bundle stdout: Nothing written bundle stderr: Nothing written > ** Invoke deploy:failed (first_time) ** Execute deploy:failed

No tengo idea de lo que está pasando ... ¿Tienes ideas antis?

EDITAR:

En la máquina virtual vagrant , .bash_profile es:

vagrant@vagrant-ubuntu-saucy-64:~$ 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*

EDITAR (25 de marzo de 2014):

Después de las sugerencias de @GhostGambler, el nuevo Capfile es:

set :default_environment, { ''PATH'' => "/usr/local/rvm/gems/ree-1.8.7-2012.02@<gemset>/bin:/usr/local/rvm/gems/ree-1.8.7-2012.02@global/bin:/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin:/usr/local/rvm/bin:$PATH", ''RUBY_VERSION'' => ''ree-1.8.7-2012.02'', ''GEM_HOME'' => ''/usr/local/rvm/gems/ree-1.8.7-2012.02@<gemset>'', ''GEM_PATH'' => ''/usr/local/rvm/gems/ree-1.8.7-2012.02@<gemset>'' #, #''BUNDLE_PATH'' => ''/usr/local/rvm/gems/ree-1.8.7-2012.02'' # If you are using bundler. } # Load DSL and Setup Up Stages require ''capistrano/setup'' # Includes default deployment tasks require ''capistrano/deploy'' require ''rvm1/capistrano3'' # Loads custom tasks from `lib/capistrano/tasks'' if you have any defined. Dir.glob(''lib/capistrano/tasks/*.cap'').each { |r| import r }

Y agregué en deploy.rb

... before ''deploy'', ''rvm1:install:gems'' namespace :deploy do ...

El error aún aparece ( RVM is not a function... ) pero puede instalar las gemas, pero ahora falla con otro error:

DEBUG [29ba9d5d] Command: cd /home/vagrant/apps/releases/20140325223229 && /tmp/arquimedes/rvm-auto.sh . gem install --file Gemfile DEBUG [29ba9d5d] RVM is not a function, selecting rubies with ''rvm use ...'' will not work. DEBUG [29ba9d5d] DEBUG [29ba9d5d] You need to change your terminal emulator preferences to allow login shell. DEBUG [29ba9d5d] Sometimes it is required to use `/bin/bash --login` as the command. DEBUG [29ba9d5d] Please visit https://rvm.io/integration/gnome-terminal/ for a example. DEBUG [29ba9d5d] DEBUG [29ba9d5d] Using execjs (2.0.2) DEBUG [29ba9d5d] Using json (1.8.1) DEBUG [29ba9d5d] Using uglifier (2.4.0) ... DEBUG [29ba9d5d] Using bootstrap-sass (3.1.1.0) DEBUG [29ba9d5d] INFO [29ba9d5d] Finished in 135.237 seconds with exit status 0 (successful). ** Execute deploy ** Invoke deploy:starting (first_time) ** Execute deploy:starting ** Invoke deploy:check (first_time) ** Execute deploy:check ** Invoke git:check (first_time) ** Invoke git:wrapper ** Execute git:check DEBUG [6f67db51] Running /usr/bin/env git ls-remote [email protected]:opintel/webapp.git on 192.168.33.10 DEBUG [6f67db51] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/arquimedes/ ... ... DEBUG [6f67db51] Finished in 4.179 seconds with exit status 0 (successful). ** Invoke deploy:check:directories (first_time) ** Execute deploy:check:directories INFO [645d5072] Running /usr/bin/env mkdir -pv /home/vagrant/apps/shared /home/vagrant/apps/releases on 192.168.33.10 DEBUG [645d5072] Command: /usr/bin/env mkdir -pv /home/vagrant/apps/shared /home/vagrant/apps/releases INFO [645d5072] Finished in 0.011 seconds with exit status 0 (successful). ** Invoke deploy:check:linked_dirs (first_time) ** Execute deploy:check:linked_dirs ** Invoke deploy:check:make_linked_dirs (first_time) ** Execute deploy:check:make_linked_dirs ** Invoke deploy:check:linked_files (first_time) ** Execute deploy:check:linked_files ** Invoke deploy:started (first_time) ** Execute deploy:started ** Invoke deploy:updating ** Invoke deploy:updated (first_time) ** Execute deploy:updated ** Invoke deploy:publishing (first_time) ** Execute deploy:publishing ** Invoke deploy:symlink:release (first_time) ** Execute deploy:symlink:release INFO [bf5c604d] Running /usr/bin/env rm -rf /home/vagrant/apps/current on 192.168.33.10 DEBUG [bf5c604d] Command: /usr/bin/env rm -rf /home/vagrant/apps/current INFO [bf5c604d] Finished in 0.011 seconds with exit status 0 (successful). INFO [72cfae75] Running /usr/bin/env ln -s /home/vagrant/apps/releases/20140325223229 /home/vagrant/apps/current on 192.168.33.10 DEBUG [72cfae75] Command: /usr/bin/env ln -s /home/vagrant/apps/releases/20140325223229 /home/vagrant/apps/current INFO [72cfae75] Finished in 0.011 seconds with exit status 0 (successful). ** Invoke deploy:restart (first_time) ** Execute deploy:restart cap aborted! ArgumentError: wrong number of arguments (1 for 0)