Skip to content

Conversation

@Edouard-chin
Copy link
Contributor

What was the end-user or developer problem that led to this PR?

Problem

Running bundle lock --add-checksums doesn't add the checksum of gems hosted on server that don't implement the compact index API.

This result in a lockfile which is unusable in production as some checksums will be missing and Bundler raising an error. Users can work around this problem by running:

  • BUNDLE_LOCKFILE_CHECKSUMS=true bundle install --force

But this means redownloading and installing all gems which isn't great and slow on large apps.

What is your fix for the problem, implemented in this PR?

Context

Bundler uses the Compact Index API to get the checksum of gems, but most private gem servers don't implement the compact index API (such as cloudsmith or packagecloud). This results in a soft failure on bundler side, and bundler leaving out blank checksum for those gems.

Solution

For gems that are hosted on private servers that don't send back the checksum of the gem, I'd like to fallback to the bundle install mechanism, which don't rely on an external API but instead compute the checksum of the package installed on disk.

This patch goes through the spec that didn't return a checksum, and compute one if the package exists on disk. This solution makes the bundle lock --add-checksums command actually usable in real world scenarios while keeping the bundle lock command fast enough.

Make sure the following tasks are checked

- ### Problem

  Running `bundle lock --add-checksums` doesn't add the checksum of
  gems hosted on server that don't implement the compact index API.

  This result in a lockfile which is unusable in production as
  some checksums will be missing and Bundler raising an error.
  Users can work around this problem by running:

  `BUNDLE_LOCKFILE_CHECKSUMS=true bundle install --force`

  But this means redownloading and installing all gems which isn't
  great and slow on large apps.

  ### Context

  Bundler uses the Compact Index API to get the checksum of gems,
  but most private gem servers don't implement the compact index API
  (such as cloudsmith or packagecloud). This results in a soft failure
  on bundler side, and bundler leaving out blank checksum for those
  gems.

  ### Solution

  For gems that are hosted on private servers that don't send back
  the checksum of the gem, I'd like to fallback to the
  `bundle install` mechanism, which don't rely on an external API but
  instead compute the checksum of the package installed on disk.

  This patch goes through the spec that didn't return a checksum,
  and compute one if the package exists on disk.
  This solution makes the  `bundle lock --add-checksums` command
  actually usable in real world scenarios while keeping the
  `bundle lock` command fast enough.
Copy link
Member

@tenderlove tenderlove left a comment

Choose a reason for hiding this comment

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

This makes sense to me

@hsbt hsbt merged commit 66c94f6 into ruby:master Oct 15, 2025
76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants