formula_creator: add deny network for ruby - #23763
Conversation
There was a problem hiding this comment.
馃煝 Approval recommended
The implementation matches the staged fetch/build lifecycle and includes focused template coverage.
Pull request overview
Updates Ruby formula templates to support network-isolated builds.
Changes:
- Cache Bundler dependencies during
fetch. - Install cached gems locally with network access denied.
- Add template-generation coverage for Ruby mode.
File summaries
| File | Description |
|---|---|
Library/Homebrew/formula_creator.rb |
Adds offline Ruby dependency handling. |
Library/Homebrew/test/formula_creator_spec.rb |
Verifies generated Ruby templates. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
馃挕 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| system "bundle", "config", "set", "force_ruby_platform", "true" | ||
| system "bundle", "config", "set", "version", "system" # Avoid installing Bundler into the keg | ||
| system "bundle", "config", "set", "without", "development test" |
There was a problem hiding this comment.
Follow-up: wonder if we can/should use default env instead for any of these.
There was a problem hiding this comment.
version and without are probably safe.
force_ruby_platform does break some packages that only provide native gems. Main one is sorbet-static which currently impacts ruby-lsp.
Though it may be better to require formula to configure the inverse so that it is more obvious when a prebuilt is used:
system "bundle", "config", "set", "force_ruby_platform", "false"EDIT: for ruby-lsp, I think it doesn't actually need sorbet-static but Bundler/RubyGem limitation requires resolving development dependencies even when we set without. We also hit this in brew.
There was a problem hiding this comment.
Though it may be better to require formula to configure the inverse so that it is more obvious when a prebuilt is used:
Good idea 馃憤馃徎
Examples for handling network access of Ruby formulae at:
deny_network_access!聽homebrew-core#302225Based on https://guides.rubygems.org/caching-and-vendoring/
Some extra notes:
bundle configto preserve config across both fetch & build phase. Could consider making this part of superenv / build environment, but would need to check on usage (and will need a way to avoid for stuff likesorbet-staticwhich currently uses prebuilt binaries)BUNDLE_PATH=.bundleis Bundler 5 default so can be removed in the future. Currently needed as RubyGems still creates some bin files for main package even when--no-installis used.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?