Skip to content

Don't warn about default gems missing from Gemfile.lock - #3209

Open
ksss wants to merge 3 commits into
ruby:masterfrom
ksss:suppress-default-gem-warning
Open

ksss wants to merge 3 commits into
ruby:masterfrom
ksss:suppress-default-gem-warning

Conversation

@ksss

@ksss ksss commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Problem

Once a default gem ships its own sig/ directory, listing that gem under gems: in rbs_collection.yaml without adding it to the Gemfile makes rbs collection install print this warning:

Cannot find `net-http` gem. Using incorrect Bundler context?

The signatures are resolved successfully, and the lockfile records the gem correctly with the rubygems source. Default gems are always installed with Ruby, so leaving one out of the Gemfile is a valid configuration, and the warning is misleading.

This did not show up before because the signatures of default gems were resolved from the stdlib/ directory bundled with rbs, and gems resolved from stdlib return before the warning check. When sig/ is installed into the gem directory of a default gem, as ruby/ruby#12541 does, the gem is resolved from the Rubygems source instead and reaches the warning about the gem missing from Gemfile.lock.

Change

LockfileGenerator now checks whether a gem missing from Gemfile.lock is a default gem, using Gem::Specification.default_stubs in a new private method default_gem?, and skips the warning if it is. default_stubs reads the gemspec directory of default gems directly, so it is not affected by Bundler replacing Gem::Specification.

Verification

  • Added a test that lists the default gem un under gems: with an empty Gemfile and asserts that the warning is not printed. The test fails without the change.
  • With Ruby 4.0.6 and 3.3.6, I temporarily put a sig/ directory into the gem directory of net-http and confirmed that the warning above is printed without the change and not printed with it.

🤖 Generated with Claude Code

ksss and others added 3 commits October 8, 2026 14:48
Default gems are always installed with Ruby, so specifying one in
`gems:` of rbs_collection.yaml without adding it to Gemfile is valid.
Skip the "Cannot find gem. Using incorrect Bundler context?" warning
for them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019wWXRc7Va2Vqk2G3BbjMWi
- Add `Gem::Specification.default_stubs` to the rubygems shim for Steep
- `set` is a default gem on Ruby < 3.5, so the warning is no longer expected there

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant