Skip to content

Add support for gems.rb and gems.locked files (fixes #325) - #418

Open
kallal79 wants to merge 6 commits into
rubysec:masterfrom
kallal79:feature/gems-rb-gems-locked-support
Open

kallal79 wants to merge 6 commits into
rubysec:masterfrom
kallal79:feature/gems-rb-gems-locked-support

Conversation

@kallal79

Copy link
Copy Markdown
Contributor

Description:
This PR implements support for alternative gemfile naming conventions (gems.rb/gems.locked)
introduced in Bundler 2.0, as requested in issue #325.

Changes Made:

  • Automatic detection of gems.locked files alongside Gemfile.lock
  • Priority system: Gemfile.lock takes precedence over gems.locked when both exist
  • Helpful error messages when gems.rb exists but gems.locked is missing
  • Updated CLI help text and documentation
  • Comprehensive test coverage for all new functionality
  • Full backward compatibility maintained

Testing:

  • All existing tests continue to pass
  • New test suite covers gems.rb/gems.locked scenarios
  • Manual testing confirms correct behavior
  • CLI help text updated appropriately

Fixes #325

postmodern and others added 6 commits February 8, 2022 14:17
- Add automatic detection of gems.locked files alongside Gemfile.lock
- Maintain priority: Gemfile.lock takes precedence over gems.locked
- Add helpful error messages when gems.rb exists but gems.locked is missing
- Update CLI help text to mention gems.rb/gems.locked support
- Add comprehensive test coverage for new functionality
- Update README.md to document alternative file naming support
- Enhance scanner with detect_gemfile() method for better error handling
- Update all documentation to reflect gems.rb/gems.locked support

This implements the feature requested in issue rubysec#325 to support
alternative gemfile names (gems.rb/gems.locked) introduced in Bundler 2.0
while maintaining full backward compatibility.
@czj

czj commented Nov 4, 2026

Copy link
Copy Markdown

A few things that look unintended or outside the scope of gems.locked support:

  • gemspec.yml: the new metadata URLs point to rubysec/bundler-audit.rb, which doesn't exist (the repo is rubysec/bundler-audit). Gem metadata deserves its own PR anyway.
  • README: the custom lockfile examples switched from --gemfile-lock to --gemfile, an option that doesn't exist.
  • Detection order: detect_lock_file picks Gemfile.lock first whenever it exists. Bundler pairs lockfiles with their Gemfile (gems.rb → gems.locked, Gemfile → Gemfile.lock), so deriving the lockfile from the detected Gemfile would match what bundle install actually uses, e.g. in a project migrating to gems.rb with a stale Gemfile.lock left behind.

A minimal PR limited to lockfile detection would be much easier to review.

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.

gems.rb and gems.locked

4 participants