bundle config で capistrano の flag is deprecated に対応する
Published: 2020/4/9
症状
[DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag
[DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path '/my/app/path/shared/bundle'`, and stop using this flag
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'development test'`, and stop using this flag
などと capistrano/bundler が warning を表示したときの対処方法。 deprecation なので、対処しなくても動きはするけれども。
原因と対策
https://github.com/capistrano/bundler/issues/115
上記の issue で議論されている。
この変更が deprecated になった理由は、 bundle install を実施する際にころころインストール先やインストール対象がそのパラメータ一つで 変化するのは、よくない(bundle config で設定すべき)という理由から。
capistrano が正しく対応するまでは、 issueに書かれていた workaround を総合して、以下の設定を config/deploy.rb
に記述すればよい。
set :bundle_flags, '--quiet' # this unsets --deployment, see details in config_bundler task details
set :bundle_path, nil
set :bundle_without, nil
namespace :deploy do
desc 'Config bundler'
task :config_bundler do
on roles(/.*/) do
within release_path do
execute :bundle, :config, '--local deployment true'
execute :bundle, :config, '--local without "development test"'
execute :bundle, :config, "--local path #{shared_path.join('bundle')}"
end
end
end
end
before 'bundler:install', 'deploy:config_bundler'
Tags: capistranobundler
関連記事
Too many authentication failures の原因と対処
2023/8/20
Capistrano3 で revision を表示する
2019/2/21