Allow declaring override remotes on a RubyGems source - #9515
Conversation
tenderlove
left a comment
There was a problem hiding this comment.
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
abcdb71 to
1c11b7d
Compare
|
Something I've noticed, it's unclear from the lockfile if a gem installed comes from the override or the rubygems.org source and it becomes harder to audit your lockfile. For example: It's hard to verify if |
1c11b7d to
3935330
Compare
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"
3935330 to
8540d48
Compare
I agree with this. It makes sense to separate them, I'm just not sure if we should make that part of this PR since I'm not sure what the impact of changing the lockfile format would be. I think we should land this and then figure out a way to fix the lockfile format. wdyt? |
A
sourcemay declare one or moreoverrides:— secondary RubyGems-compatible repositories that supply alternate builds (for example, prebuilt binaries) of gems that already exist in the primary source.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.lockunderoverride:lines:Questions
I don't know if
overridesis the correct name. We consideredmirrorbut it's not a true mirror. andbinary _sourcesbut 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