2016-10-12 11 views
0

capistrano-rbenvでCapistrano 3を使用しているときにruby gemコマンドを実行する際に問題があります(Rubyインタプリタが見つからないと仮定しています) )、特にdelayed_job。問題に関連する必要なファイルを投稿しました。Capistrano 3 rbenv問題:ロードするファイルがありません - ruby​​gems(LoadError)

`require': no such file to load -- rubygems (LoadError) 

ご協力いただければ幸いです。

Gemfile

gem 'capistrano', "~> 3.6" 
gem 'capistrano-rbenv', '~> 2.0' 

Capfile

# Load DSL and set up stages 
require "capistrano/setup" 

# Include default deployment tasks 
require "capistrano/deploy" 
require "capistrano/rbenv" 

# Load custom tasks from `lib/capistrano/tasks` if you have any defined 
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } 

deploy.rb

# config valid only for current version of Capistrano 
lock '3.6.1' 

set :application, 'youtube_rank_tracker' 
set :repo_url, './.git' 

# Default branch is :master 
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp 

# Default deploy_to directory is /var/www/my_app_name 
set :deploy_to, '/dogecoin' 

# Default value for :scm is :git 
set :scm, :git 

# Default value for :format is :airbrussh. 
set :format, :airbrussh 

# You can configure the Airbrussh format using :format_options. 
# These are the defaults. 
set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto 

# Default value for :pty is false 
set :pty, true 

# Default value for :linked_files is [] 
# append :linked_files, 'config/database.yml', 'config/secrets.yml' 

# Default value for linked_dirs is [] 
# append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system' 

# Default value for default_env is {} 
# set :default_env, { path: '$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH' } 

# Default value for keep_releases is 5 
set :keep_releases, 5 

# set :default_env, { path: "$HOME/.rbenv/bin:$PATH" } 
set :rbenv_type, :user # or :system, depends on your rbenv setup 
set :rbenv_ruby, '2.1.2' 
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 

namespace :deploy do 
    desc 'Restart application' 
    task :restart do 
    on roles(:all) do |host| 
     execute :mkdir, "-p #{release_path}/tmp" 
     execute :touch, release_path.join('tmp/restart.txt') 
     execute "cd #{release_path} && RAILS_ENV=production bin/delayed_job restart;" 
     # execute "cd #{release_path} && bundle exec rake -T" 
    end 
    end 
end 

after 'deploy:publishing', 'deploy:restart' 

エラー

he deploy has failed with an error: Exception while executing as [email protected]: cd /.... && RAILS_ENV=production bin/delayed_job restart; exit status: 1 
cd /.... && RAILS_ENV=production bin/delayed_job restart; stdout: /usr/lib/ruby/vendor_ruby/bundler/shared_helpers.rb:2:in `require': no such file to load -- rubygems (LoadError) 
    from /usr/lib/ruby/vendor_ruby/bundler/shared_helpers.rb:2 
    from /usr/lib/ruby/vendor_ruby/bundler/setup.rb:1:in `require' 
    from /usr/lib/ruby/vendor_ruby/bundler/setup.rb:1 

答えて

1

短い答え

の代わりにそれを自分で書いて、半公式カピストラーノ3遅延ジョブ統合宝石を使用します。https://github.com/AgileConsultingLLC/capistrano3-delayed-job

長い答え

あなたが実際にこれを自分で書くとしたら、カピストラーノ-rbenvのみ影響しますここに見られるように、コマンドの小さなデフォルトのリスト、:

namespace :deploy do 
    desc 'Restart application' 
    task :restart do 
    on roles(:all) do |host| 
     within release_path do 
     execute :ruby, "bin/delayed_job", 'restart' 
     end 
    end 
    end 
end 
:この場合 https://github.com/capistrano/rbenv/blob/master/lib/capistrano/tasks/rbenv.rake#L47

は、おそらく次のような何かをしたいと思います

tmp/ディレクトリを作成する代わりに、設定ファイルの:linked_dirsに追加します。

さらに、tmp/restart.txtに触れてPassengerを再起動したようです。あるいは、カピストラーノパッセンジャーの宝石を使ってそれを行うこともできます。これは、より新しいモードで実行することができます。これは、乗客のコマンドを使用してアプリを再起動するか、タッチファイルメカニズムを使用するように指示することができます。

最後に、cd ${release_path}を使用する代わりに、within DSLメソッドを使用します。それは同じことを達成し、コマンドマップを破ることはありません。

+0

ありがとうございます!私はcapistranoのために遅れた仕事の宝石を試しました、そして、それは正常に動作していなかった、バンドラーエラーを取得しましたが、単純にあなたが投稿したコードをエミュレートしました。 – icantbecool

関連する問題