Skip to content

Commit eefc7b9

Browse files
authored
Add Bundler v4 opt-in to fix config deprecation warning (#137)
1 parent 0a5b9dd commit eefc7b9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ set :bundle_flags, '--quiet' # this is defaul
8383
set :bundle_env_variables, {} # this is default
8484
set :bundle_clean_options, "" # this is default. Use "--dry-run" if you just want to know what gems would be deleted, without actually deleting them
8585
set :bundle_check_before_install, true # default: true. Set this to false to bypass running `bundle check` before executing `bundle install`
86+
set :bundle_version, 2 # default: 2. Set to 4 for Bundler 4 compatibility
87+
```
88+
89+
If you are using Bundler 4 (which is the default in Ruby 4),
90+
make sure to set `:bundle_version` to avoid deprecation warnings:
91+
92+
```ruby
93+
set :bundle_version, 4
8694
```
8795

8896
You can parallelize the installation of gems with bundler's jobs feature.

lib/capistrano/tasks/bundler.cap

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ namespace :bundler do
1616
on fetch(:bundle_servers) do
1717
within release_path do
1818
with fetch(:bundle_env_variables) do
19+
config_args = fetch(:bundle_version, 2) >= 4 ? %w[config set] : %w[config]
20+
1921
configuration = fetch(:bundle_config).dup || {}
2022
configuration[:gemfile] = fetch(:bundle_gemfile)
2123
configuration[:path] = fetch(:bundle_path)
2224
configuration[:without] = fetch(:bundle_without)
2325

2426
configuration.each do |key, value|
25-
execute :bundle, "config", "--local", key, value.to_s.shellescape unless value.nil?
27+
execute :bundle, *config_args, "--local", key, value.to_s.shellescape unless value.nil?
2628
end
2729
end
2830
end
@@ -52,6 +54,8 @@ namespace :bundler do
5254
set :bundle_jobs, 4
5355
set :bundle_env_variables, {}
5456
set :bundle_clean_options, ""
57+
set :bundle_check_before_install, true
58+
set :bundle_version, 2
5559
DESC
5660
task install: :config do
5761
on fetch(:bundle_servers) do
@@ -124,5 +128,6 @@ namespace :load do
124128
set :bundle_env_variables, {}
125129
set :bundle_clean_options, ""
126130
set :bundle_check_before_install, true
131+
set :bundle_version, 2
127132
end
128133
end

0 commit comments

Comments
 (0)