web-dev-qa-db-ja.com

capistranoからバンドルインストールが機能しない

単純なRails 4.0アプリケーションをcapistrano 3.0経由でデプロイしたい。

bundler 1.3.5を使用するので、 capistrano-bundler gemを追加してbundlerをcapistranoに統合します。

私は非常に単純な構成を持っています(ほぼデフォルト):

set :bundle_gemfile, -> { release_path.join('Gemfile') }
set :bundle_dir, -> { shared_path.join('bundle') }
set :bundle_flags, ''
set :bundle_without, %w{test development}.join(' ')
set :bundle_binstubs, -> { shared_path.join('bin') }
set :bundle_roles, :all

cap staging deploy --traceを実行すると失敗します:

[50b524bc] Running /usr/bin/env bundle --gemfile /home/webmaster/www/api/releases/20131014144650/Gemfile --path /home/webmaster/www/api/shared/bundle  --binstubs /home/webmaster/www/api/shared/bin --without test development on 125.51.3.1
DEBUG [50b144bc] Command: cd /home/webmaster/www/api/releases/20131014144650 && /usr/bin/env bundle --gemfile /home/webmaster/www/api/releases/20131014144650/Gemfile --path /home/webmaster/www/api/shared/bundle  --binstubs /home/webmaster/www/api/shared/bin --without test development
cap aborted!
bundle stdout: Nothing written
bundle stderr: Nothing written
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/command.rb:94:in `exit_status='
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/capistrano-bundler-1.0.0/lib/capistrano/tasks/bundler.cap:20:in `block (4 levels) in <top (required)>'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/abstract.rb:81:in `within'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/capistrano-bundler-1.0.0/lib/capistrano/tasks/bundler.cap:19:in `block (3 levels) in <top (required)>'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run'
/home/omnomnom/.rvm/gems/Ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:updated => bundler:install

しかし、このコマンドをコピーしてsshがすべて正常に動作する場合(すべてのgemが正常にインストールされた場合)修正/デバッグする方法を教えてください。

31
freemanoid

ちょうど同じ問題に遭遇しました。私のために働いたのはこれでした:

1)capistrano-rvm gemのインストールと追加

require 'capistrano/rvm'

Capfileに。

2)サーバー上のrvmグループに展開ユーザーを追加します。

# usermod deploy -a -G rvm

3)展開ユーザーのホームフォルダーに.rvm.rvm/binの2つのディレクトリを作成します

4)deploy.rbファイルに次の行を追加します。

set :default_env, { rvm_bin_path: '~/.rvm/bin' }

ふう!それには数時間かかりました。

50

エラーは、bundlePATHが見つからないようです。手動でSSHで接続すると、~/.profileまたは~/.bash_profileで何かを実行してパスに追加する可能性があります。

ログインしてwhich bundleを実行し、bundleへのパスを見つけます。次に、そのパスがPATH環境変数に追加される方法を見つけてください。代わりに~/.bash_profile, try moving it to〜/ .bashrc`に何かがある場合。

コマンドマッピング を試して、正確なパスを指定することもできます。

http://www.capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-でいくつかのトラブルシューティングのヒントがありますカピストラーノ/

12
Tim Moore

シンプルなソリューションとすべてのCapistrano 3バージョンでの作業:

gem 'rvm1-capistrano3', require: false

Capfileに追加

require 'rvm1/capistrano3'

https://github.com/rvm/rvm1-capistrano

3
Nesha Zoric

私の場合、config/deploy.rbのset :log_level, :infoからset :log_level, :debug、「GEMFILEが見つかりません」と表示されました。これにより、bundleが間違った作業ディレクトリで実行されていることが示唆されたため、変更しました

before "deploy:assets:precompile", "deploy:bundle_install"
desc "Bundle install for RVMs sake"
task :bundle_install do
  on roles(:app) do
    execute "/u0/jrepenni/.rvm/bin/rvm 2.1.0@akiary do /u0/jrepenni/.rvm/gems/Ruby-2.1.0@global/bin/bundle install"
  end
end

before "deploy:assets:precompile", "deploy:bundle_install"
desc "Bundle install for RVMs sake"
task :bundle_install do
  on roles(:app) do
    execute "cd #{release_path} && /u0/jrepenni/.rvm/bin/rvm 2.1.0@akiary do /u0/jrepenni/.rvm/gems/Ruby-2.1.0@global/bin/bundle install"
  end
end

(追加された「cd」に注意してください)

2
jackr

私が持っていた:

set :bundle_flags, '--system --quiet'

変更後:

set :bundle_flags, '--deployment --quiet'

これで問題は解決しました。

1
Alex Fedoseev
gem install bundler 

capistranoを使用するために、デプロイユーザーで実行する必要がありました。

/usr/local/rvm/bin/rvm 2.4.0 do bundle install --path /var/www/hivebench-api/shared/bundle --without development test --deployment --quiet

合格する!

0

config/deploy/production.rbファイルに

set :rvm_Ruby_version, '2.0.0-p247'  

https://github.com/capistrano/rvm を参照してください

0
user1130176

これはcapistrano 3:で動作します

  task :bundle_list do
    on roles(:app) do
      within release_path do
        with Rails_env: fetch(:Rails_env) do
          execute :bundle, "list"
        end
      end
    end
  end

これをrakeタスクに使用します:

execute :rake, 'some_rake_task'
0
Alain Beauvois