Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit bundler:config step to support 2.1+ #122

Merged
merged 3 commits into from
Jul 11, 2020

Conversation

mattbrictson
Copy link
Member

@mattbrictson mattbrictson commented Jun 28, 2020

Starting with Bundler 2.1, the --path, --without, and --deployment options are deprecated. In other words you are no longer supposed to specify these when running bundle install.

Instead, Bundler wants you to set these options externally from the install command. That way all subsequent invocations of bundler can use the same external configuration without you having to remember which flags to use each time.

There are two ways to specify this external configuration: providing environment variables, or running bundle config. This commit implements the latter.

To summarize, prior to running bundle check, bundle install, or bundle clean, Capistrano will now run a new bundler:config task. This task executes the following command as many times as needed:

bundle config --local KEY VALUE

Each execution sets the external Bundler configuration KEY to VALUE.

The following Capistrano variables are automatically consulted to get these KEYs and VALUEs:

  • :bundle_gemfile
  • :bundle_path
  • :bundle_without

This commit also introduces a new variable:

  • :bundle_config

It is a Hash that can contain any arbitrary KEY and VALUE pairs to send to bundle config. By default it has a single entry:

set :bundle_config, { deployment: true }

Finally, this commit removes --deployment option from the default value of :bundle_flags, since that flag is deprecated. It has been replaced by the default :bundle_config as mentioned above.

Fixes #115

@capistrano-bot
Copy link

Thanks for the PR! This project lacks automated tests, which makes reviewing and approving PRs somewhat difficult. Please make sure that your contribution has not broken backwards compatibility or introduced any risky changes.

Generated by 🚫 Danger

Starting with Bundler 2.1, the `--path`, `--without`, and `--deployment`
options are deprecated. In other words you are no longer supposed to
specify these when running `bundle install`.

Instead, Bundler wants you to set these options _externally_ from the
install command. That way all subsequent invocations of bundler can use
the same external configuration without you having to remember which
flags to use each time.

There are two ways to specify this external configuration: providing
environment variables, or running `bundle config`. This commit
implements the latter.

To summarize, prior to running `bundle check`, `bundle install`, or
`bundle clean`, Capistrano will now run a new `bundler:config` task.
This task executes the following command as many times as needed:

```
bundle config --local KEY VALUE
```

Each execution sets the external Bundler configuration KEY to VALUE.

The following Capistrano variables are automatically consulted to get
theses KEYs and VALUEs:

- :bundle_gemfile
- :bundle_path
- :bundle_without

This commit also introduces a new variable:

- bundle_config

It is a Hash that can contain any arbitrary KEY and VALUE pairs to send
to `bundle config`. By default it has a single entry:

```
set :bundle_config, { deployment: true }
```

Finally, this commit removes `--deployment` option from the default
value of `:bundle_flags`, since that flag is deprecated. It has been
replaced by the default `:bundle_config` as mentioned above.
Copy link

@mauromorales mauromorales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested and works as expected, changes LGTM

@mattbrictson
Copy link
Member Author

I want to give a shout out to @spajic who proposed similar changes a few years ago in #97 and #101. Sorry it took so long. 😅

@mattbrictson
Copy link
Member Author

@will-in-wi @ansonhoyt @jamesw @tsechingho @patsch any thoughts on this PR? It would be great if you could test out this branch to see if it works prior to me merging this. Thanks!

You can test by modifying your Gemfile as follows:

gem "capistrano-bundler", git: "https://github.com/capistrano/bundler.git", branch: "features/bundler-2.1-support"

@tsechingho
Copy link

tsechingho commented Jul 8, 2020

I had test this PR in my current projects, it works as old days.
thanks @mattbrictson 😄

@ccasabona
Copy link

The 'features/bundler-2.1-support' branch works perfectly when deploying to staging and production environments. The necessary bundle config commands run as such:

00:10 bundler:config
      01 /var/www/html/example.com/public/rvm1scripts/rvm-auto.sh . bundle config --local deployment true
    ✔ 01 user@192.168.1.107 2.421s
      02 /var/www/html/example.com/public/rvm1scripts/rvm-auto.sh . bundle config --local path /var/www/html/example.com/public/shared/bundle
    ✔ 02 user@192.168.1.107 2.341s
      03 /var/www/html/example.com/public/rvm1scripts/rvm-auto.sh . bundle config --local without development\ test
    ✔ 03 user@192.168.1.107 2.380s
00:18 bundler:install
      01 /var/www/html/example.com/public/rvm1scripts/rvm-auto.sh . bundle install --jobs 4 --quiet

Thank you for making this change!

@mattbrictson
Copy link
Member Author

Alright I'm going to merge this and release a 2.0 version of this gem within the next few days. Thanks everyone!

@mattbrictson mattbrictson merged commit 148b31f into master Jul 11, 2020
@mattbrictson mattbrictson deleted the features/bundler-2.1-support branch July 11, 2020 03:27
@Fjan
Copy link

Fjan commented Jul 13, 2020

There is a small issue with this patch: bundler install wants a space separated list of groups, but bundler config wants a ":" separated list of groups (see https://bundler.io/v2.0/man/bundle-config.1.html).

We now emit the options designed for install to config, so as a space separated list, which will show a warning in bundler, but otherwise seems to work. It would be better to replace the space with a ":" in bundler-capistrano. As a quick fix to get rid of the warning you can simply do set :bundle_without, %w{development test}.join(':')

@mattbrictson
Copy link
Member Author

@Fjan thanks for the heads up and the link to the docs. Somehow I missed this warning in my testing. Could you open a new issue with some more details, including the text of the warning so that others can search for it and find it? I can implement the fix that you mentioned.

@ansonhoyt
Copy link

👍 Just deployed with capistrano-bunder 2.0.1. No bundler warnings. Many thanks! ❤️

Sorry I wasn't available to test this before release, but glad several others were able to test it out.

@thbar
Copy link

thbar commented Feb 19, 2021

Thanks for the work on this! FWIW, I'm asking Bundler if we could have a single call to set 3 options here rubygems/rubygems#4392, in order to accelerate deployment further (since the 3 steps can take near 10 seconds in cases, which could be divided by three).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ Breaking Introduces a backwards-incompatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bundler 2.1 has deprecated --deployment, --path, and --without
8 participants