Closed tolhzar closed 10 years ago
You have to jump into the app directory and then execute:
~/.rvm/bin/app_bundle exec rake ...
Deploy fails on precompile task which is a part of capistrano-rails. So I can't change that behavior:
namespace :assets do
task :precompile do
on roles :web do
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, "assets:precompile"
end
end
end
end
rake here will be pointed to ~/.rvm/bin/app_rake and won't work
Any ideas?
Are you sure capistrano/bundler
is required and you run it with bundle exec
?
~/.rvm/bin/app_rake fails due to gem not found issue.
could you also give the full error trace?
This is my Capfile
# Load DSL and Setup Up Stages require 'capistrano/setup' # Includes default deployment tasks require 'capistrano/deploy' # Includes tasks from other gems included in your Gemfile # # For documentation on these, see for example: # # https://github.com/capistrano/rvm # https://github.com/capistrano/rbenv # https://github.com/capistrano/chruby # https://github.com/capistrano/bundler # https://github.com/capistrano/rails/tree/master/assets # https://github.com/capistrano/rails/tree/master/migrations # require 'capistrano/rvm' # require 'capistrano/rbenv' # require 'capistrano/chruby' 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 }
deploy.rb
set :application, 'app' set :repo_url, 'repo' # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp } # set :deploy_to, '/var/www/my_app' set :deploy_via, :copy #set :format, :pretty #set :log_level, :debug #set :pty, true set :linked_files, %w{config/database.yml} set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads} # set :default_env, { path: "/opt/ruby/bin:$PATH" } set :keep_releases, 4 namespace :deploy do desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do # Your restart mechanism here, for example: execute :touch, release_path.join('tmp/restart.txt') end end after :finishing, 'deploy:cleanup' end
production.rb
set :stage, :production set :rvm_type, :user set :rvm_ruby_version, "ruby-2.0.0-p247@app" role :app, "ip" role :web, "ip" role :db, "ip" server "ip", user: "user", roles: %{web app db}, ssh_options: { user: "user", password: "password", forward_agent: true, auth_methods: %w(password) } set :user, "user" set :deploy_to, "path_to_app" set :rails_env, :production
Error message
INFO [ec493fba] Running ~/.rvm/bin/app_rake db:migrate on ip DEBUG [ec493fba] Command: cd /home/user/www/app/releases/20131015212409 && ( RAILS_ENV=production ~/.rvm/bin/app_rake db:migrate ) DEBUG [ec493fba] /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize' DEBUG [ec493fba] : DEBUG [ec493fba] Could not find i18n-0.6.5 in any of the sources DEBUG [ec493fba] ( DEBUG [ec493fba] Bundler::GemNotFound DEBUG [ec493fba] ) DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:13:in `setup' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.3.3/lib/rubygems-bundler/noexec.rb:74:in `setup' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.3.3/lib/rubygems-bundler/noexec.rb:103:in `check' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.3.3/lib/rubygems-bundler/noexec.rb:109:in `' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/rubygems-bundler-1.3.3/lib/rubygems_executable_plugin.rb:4:in `block in ' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/executable-hooks-1.2.3/lib/executable-hooks/hooks.rb:50:in `call' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/executable-hooks-1.2.3/lib/executable-hooks/hooks.rb:50:in `block in run' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/executable-hooks-1.2.3/lib/executable-hooks/hooks.rb:49:in `each' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/executable-hooks-1.2.3/lib/executable-hooks/hooks.rb:49:in `run' DEBUG [ec493fba] DEBUG [ec493fba] DEBUG [ec493fba] from /home/user/.rvm/gems/ruby-2.0.0-p247@global/bin/ruby_executable_hooks:10:in ` ' DEBUG [ec493fba] cap aborted! rake stdout: Nothing written rake stderr: Nothing written /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/command.rb:94:in `exit_status=' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:54:in `execute' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/capistrano-rails-1.0.0/lib/capistrano/tasks/migrations.rake:8:in `block (5 levels) in ' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/abstract.rb:89:in `with' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/capistrano-rails-1.0.0/lib/capistrano/tasks/migrations.rake:7:in `block (4 levels) in ' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/abstract.rb:81:in `within' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/capistrano-rails-1.0.0/lib/capistrano/tasks/migrations.rake:6:in `block (3 levels) in ' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run' /home/guzarevicha/.rvm/gems/ruby-2.0.0-p247@app/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' Tasks: TOP => deploy:migrate
Thanks! Could you try to move require 'capistrano/bundler'
up to place it before require 'capistrano/rvm'
?
@kirs it should not have made difference - it did not made difference in cap2 .. is it a bug?
The RVM gem extension cannot detect bundler is loaded if bundler isn't yet loaded!
On Tuesday, October 15, 2013, Michal Papis wrote:
@kirs https://github.com/kirs it should not have made difference - it did not made difference in cap2 .. is it a bug?
— Reply to this email directly or view it on GitHubhttps://github.com/capistrano/rvm/issues/12#issuecomment-26374817 .
http://lee.hambley.name/ +49 (0) 170 298 5667
@kirs Didn't help
@leehambley but bundler could detect commands and use (.*)rake
=> \1bundle exec rake
Any other ideas?
Is this bug version 2 or 3? I experience this as well in version 3 Do you have a workaround at hand?
@MichaelSp version 3 I used old syntax and locally changed capistrano-rails gem. See example below
task :compile_non_digest do on roles :web do within release_path do with rails_env: fetch(:rails_env) do execute "cd #{release_path} && RAILS_ENV=#{fetch(:rails_env)} ~/.rvm/bin/app_bundle exec rake non_digested" end end end end
Just found even better and cleaner way:
task :precompile do on roles :web do within release_path do with rails_env: fetch(:rails_env) do execute :bundle, "exec rake assets:precompile" end end end end
btw, there is a pull request fixing this in capistrano-rails https://github.com/capistrano/rails/pull/20
Hi guys,
This command
~/.rvm/bin/app_bundle --gemfile /home/user/www/app/releases/20131015200101/Gemfile --path /home/user/www/app/shared/bundle --deployment --quiet --binstubs /home/user/www/app/shared/bin --without development test
will install gems intoshared/bundle
directory and correct rake will be placed intoshared/bin
directory.bundle exec
command still works perfectly while~/.rvm/bin/app_rake
fails due to gem not found issue.Regards, Anatoly