Skip to content

Commit

Permalink
Add Bundler 2.4 to documentation
Browse files Browse the repository at this point in the history
Including release blog post and What's new page.
  • Loading branch information
deivid-rodriguez committed Jan 31, 2023
1 parent bf423e8 commit 9395eb9
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 1 deletion.
167 changes: 167 additions & 0 deletions source/blog/2023-01-31-bundler-v2-4.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
---
title: "Bundler v2.4: new resolver, gems with Rust extensions, and more"
date: 2023-01-31 14:43 UTC
tags:
author: David Rodríguez
author_url: https://github.com/deivid-rodriguez
category: release
---

2022 has been a busy year for the Bundler team, and we're glad to present
several improvements that we hope will make our users happy :)

## A better, PubGrub based, resolver

Bundler now uses the most advanced algorithm to resolve versions, PubGrub.
Kudos to Natalie Weizenbaum for [inventing
it](https://nex3.medium.com/pubgrub-2fb6470504f) and to John Hawthorn for
[porting it to Ruby](https://github.com/jhawthorn/pub_grub)!

Our previous resolver, [Molinillo](https://github.com/CocoaPods/Molinillo), worked pretty well, but it really got in the
middle when it didn't.

This may sound familiar for some:

~~~
$ bundle
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^C
$ # Ok, that was enough waiting
~~~

Our new resolver, PubGrub, is usually much faster, because it learns from the
resolution conflicts it finds during the resolution process to avoid redoing the
same work over and over again. You can find more about this "conflict-driven
clause learning" techniques in its [presentation blog
post](https://nex3.medium.com/pubgrub-2fb6470504f) back from 2018.

Molinillo sometimes took too long to resolve because it would try the same
things, backtrack, and run into the same conflicts over and over again, having
to traverse very inefficiently a huge search space. But that was a relatively
rare case in the real world.

What's probably more common is specifying version requirements in your Gemfile,
that can't be all satisfied at the same time. This is when the version solving
problem does not have a solution, and when it becomes crucial to explain to users
_why_, so that they can fix their set of version requirements to become
solvable.

Molinillo run into trouble here, and in cases with many moving parts, like
upgrading Rails for example, it could end up printing a lot of conflicts, not
easy to understand and solve. This is an old example from a public ticket:

~~~
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
inherited_resources (= 1.6.0) was resolved to 1.6.0, which depends on
actionpack (>= 3.2, < 5)
rails (= 4.2.0) was resolved to 4.2.0, which depends on
actionpack (= 4.2.0)
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
inherited_resources (= 1.6.0) was resolved to 1.6.0, which depends on
has_scope (~> 0.6.0.rc) was resolved to 0.6.0, which depends on
activesupport (>= 3.2, < 5)
rails (= 4.2.0) was resolved to 4.2.0, which depends on
activesupport (= 4.2.0)
Bundler could not find compatible versions for gem "railties":
In Gemfile:
inherited_resources (= 1.6.0) was resolved to 1.6.0, which depends on
railties (>= 3.2, < 5)
rails (= 4.2.0) was resolved to 4.2.0, which depends on
railties (= 4.2.0)
inherited_resources (= 1.6.0) was resolved to 1.6.0, which depends on
responders was resolved to 1.1.2, which depends on
railties (>= 3.2, < 4.2)
~~~

Not easy to know what to do about it.

With PubGrub, you should now get human-readable explanations of failures. The
most complex cases may are still, well... complex. But explanations should
always make sense and point to the root cause of resolution failures.

Here's an example from our test suite:

~~~
Because every version of c depends on a < 1
and every version of b depends on a >= 2,
every version of c is incompatible with b >= 0.
So, because Gemfile depends on b >= 0
and Gemfile depends on c >= 0,
version solving has failed.
~~~

We tried to make this migration as backwards-compatible as possible, but
there's a chance of experiencing some different solutions to the ones found by
Molinillo, since the version solving problem does not have unique solutions.
Please report any issues you find with the new resolver.


### Easily generate gems with Rust extensions using `bundle gem`

It's now easier than ever to get started using Rust inside your gems. Check out
[this blog post](rust-gem-skeleton.html) to learn how to generate a gem with all
the boilerplate necessary with just a few commands.

### Faster git sources

In the Bundler world, it's common to point to git repositories when there's
no version released to rubygems.org that includes the changes that you need.
This works fine, but it can get slow and use a lot of disk space when dealing
with very big repositories.

We have improved the way we clone these repositories to be faster and use less
disk space. For example, something like

```ruby
gem "rails", github: "rails/rails"
```

in your Gemfile could previously take ~30s and use up to 1Gb of disk space,
because we would clone the full Rails repository, which has a large history.

Now we just clone what's strictly necessary for Bundler to work, resulting in
big disk space savings, and much faster bundling.

### New CLI features

We added a few small CLI features, such as a new `--pre` flag to `bundle update`
and `bundle lock` to explicitly opt-in to prereleases of selected (of all) gems
without having to explictly change your Gemfile with pre-release requirements
such as `>= 7.1.0.beta`.

### Some minor breaking changes

We took new year's release to move on and get rid of some stuff that was causing
maintenance burden for us:

* Ruby 2.3, 2.4, and 2.5 are no longer supported.
* RubyGems 2.5, 2.6, and 2.7 are no longer supported.

In general, this support drop should not break anything because RubyGems should
be able to choose the latest supported Bundler on the Ruby version that you're
using. But there are still some old RubyGems out there that don't have this
feature, and the `gem install bundler` command could break there. We have
warned using Bundler on those old rubies for a year now, so we believe it's time
to move on.

We also completely removed a controversial (mis-)feature from the Bundler code
base, where Bundler would automatically acquire sudo permissions when not having
the proper access rights. A great majority of users considered this feature harmful and
hardly useful, so we decided to get rid of it.

### And bug fixes

As always, we continue to smooth the experience of using Bundler, so that it
gets the job done and does not get in the middle other than that. And we're also
shipping a bunch of bug fixes to keep moving towards that goal.

That's all from the Bundler team. Have a happy new year, and enjoy using Bundler
2.4! 🎉
33 changes: 32 additions & 1 deletion source/v2.4/whats_new.html.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
# What's New in v2.4

As always, a detailed list of every change is provided in
The [Bundler 2.4 announcement](/blog/2022/12/22/bundler-v2-4.html)
includes context and a more detailed explanation of the changes in this version. This is a summary of the biggest changes. As always, a detailed list of every change is provided in
[the changelog](https://github.com/rubygems/rubygems/blob/3.4/bundler/CHANGELOG.md).

### A new PubGrub based resolver

Bundler now uses [pub_grub](https://github.com/jhawthorn/pub_grub) under the
hood to resolve versions. The most advance algorithm to approach the version
solving problem! 💪

### Generate gems with Rust extensions

`bundle gem` now supports Rust! Pass the `--ext=rust` flag to generate a gem
with a Rust extension.

### Faster git sources in Gemfile

Git sources in Gemfile now work faster and use less disk space.

### Old Ruby and RubyGems no longer supported

Support for Ruby 2.3, 2.4, and 2.5, and RubyGems 2.5, 2.6, and 2.7 has been dropped.

### No more auto-sudo

Bundler no longer tries to use `sudo` to upgrade privileges under any circumstances.

### Other improvements

Bundler 2.4 also includes other improvements like a new `--pre` flag
to `bundle lock` and `bundle update` to explicitly opt-in to prereleases.

<a href="https://github.com/rubygems/rubygems/blob/3.4/bundler/CHANGELOG.md" class="btn btn-primary">Full 2.4 changelog</a>

0 comments on commit 9395eb9

Please sign in to comment.