Skip to content

Suppress spurious warning for non-gem stdlib libraries#2929

Merged
soutaro merged 1 commit intomasterfrom
stdlib-message
Apr 9, 2026
Merged

Suppress spurious warning for non-gem stdlib libraries#2929
soutaro merged 1 commit intomasterfrom
stdlib-message

Conversation

@soutaro
Copy link
Copy Markdown
Member

@soutaro soutaro commented Apr 9, 2026

Summary

  • Add NONGEM_STDLIBS constant listing standard libraries that are not distributed as gems (e.g., socket, pathname, monitor) but have type definitions in stdlib/
  • Skip the "Cannot find <name> gem" warning for these libraries during rbs collection install
  • Add test to verify no warning is emitted when non-gem stdlibs are in the lockfile

Problem

When rbs_collection.yaml includes non-gem standard libraries like socket, running rbs collection install a second time (with an existing lockfile) emits a misleading warning:

Cannot find `socket` gem. Using incorrect Bundler context?

This happens because with an existing lockfile, assign_gem takes the existing_lockfile code path, bypassing stdlib detection via find_source. It then checks gem_hash (Bundler's specs) which naturally doesn't include non-gem libraries, triggering the warning.

🤖 Generated with Claude Code

When running `rbs collection install` with an existing lockfile that
includes non-gem standard libraries (like socket, pathname), the
lockfile generator would emit a misleading warning:

  Cannot find `socket` gem. Using incorrect Bundler context?

This happens because these libraries are part of Ruby's standard
library but are not distributed as gems, so they never appear in
Bundler's gem specifications. With an existing lockfile, the code
path bypasses stdlib detection and falls through to the gem_hash
lookup, which fails and triggers the warning.

Add NONGEM_STDLIBS constant listing all non-gem standard libraries
that have type definitions in stdlib/, and skip the warning for them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@soutaro soutaro added this to the RBS 4.1 milestone Apr 9, 2026
@soutaro soutaro merged commit a277a21 into master Apr 9, 2026
25 of 26 checks passed
@soutaro soutaro deleted the stdlib-message branch April 9, 2026 14:31
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