Skip to content

Allow declaring override remotes on a RubyGems source#9515

Open
eileencodes wants to merge 1 commit intoruby:masterfrom
eileencodes:bundler-override-sources
Open

Allow declaring override remotes on a RubyGems source#9515
eileencodes wants to merge 1 commit intoruby:masterfrom
eileencodes:bundler-override-sources

Conversation

@eileencodes
Copy link
Copy Markdown
Member

A source may declare one or more overrides: — secondary RubyGems-compatible repositories that supply alternate builds (for example, prebuilt binaries) of gems that already exist in the primary source.

source "https://rubygems.org",
       overrides: ["https://build-farm.example.com"]

Override remotes are consulted only for gems that are also present in the primary source; they cannot introduce new gems. When an override publishes a spec whose name and version match one in the primary source, that spec is preferred for installation if it is compatible with the local platform. If no matching build is available, or fetching the override fails (authentication, SSL, or network errors), Bundler falls back to the primary source.

Override remotes are recorded in Gemfile.lock under override: lines:

GEM
  remote: https://rubygems.org/
  override: https://build-farm.example.com/
  specs:

Questions

I don't know if overrides is the correct name. We considered mirror but it's not a true mirror. and binary _sources but that feels too specific. Open to ideas and changes. I decided not to spend more time on the name since we will end up discussing and debating on the PR anyway.

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

If we were going to build a build farm, we'd need a way to define those sources. We could use the source block format but that's not a super user-friendly API since users would need to know which gems are precompiled. We considered reintroducing top-level mulit-source but we've need to handle the security implications. We came up with this API that has a source that can't introduce new gems because they must be present in the primary source.

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

See commit message

Make sure the following tasks are checked

cc/ @tenderlove @jenshenny

Copy link
Copy Markdown
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.

If I'm reading this correctly, it looks like we just emit a warning (and skip) if there's an override that doesn't exist in the main source. Shouldn't we raise an exception instead? It seems like a bug if there's an override but no canonical version

@eileencodes eileencodes force-pushed the bundler-override-sources branch from 8447096 to abcdb71 Compare May 4, 2026 15:16
A `source` may declare one or more `overrides:` — secondary
RubyGems-compatible repositories that supply alternate builds (for
example, prebuilt binaries) of gems that already exist in the primary
source.

  source "https://rubygems.org", overrides: ["https://build-farm.example.com"]

Override remotes are consulted only for gems that are also present in
the primary source; they cannot introduce new gems. When an override
publishes a spec whose name and version match one in the primary
source, that spec is preferred for installation if it is compatible
with the local platform. If no matching build is available, or
fetching the override fails (authentication, SSL, or network errors),
Bundler falls back to the primary source.

Override remotes are recorded in `Gemfile.lock` under `override:` lines:

  GEM
    remote: https://rubygems.org/
    override: https://build-farm.example.com/
    specs:

IRL Testing:

This can be exercised against Kou's precompiled-gems build farm
hosted on Cloudsmith. The only build target currently published there
is Ruby 4.0 on amd64 Ubuntu 24.04 — on any other platform the
override is skipped and Bundler falls back to the primary source.

  source "https://rubygems.org",
         overrides: ["https://dl.cloudsmith.io/public/rubygems-precompiled-gems/ruby-4-0-amd64-ubuntu-24-04/ruby/"]

  # Precompiled binaries are available on the override remote:
  gem "json"
  gem "openc3"
  gem "io-event"

  # Not in the override; fall back to rubygems.org and compile
  # from source:
  gem "nokogiri"
  gem "rails"
@eileencodes eileencodes force-pushed the bundler-override-sources branch from abcdb71 to 1c11b7d Compare May 5, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants