Repository navigation
Conversation
acecilia
marked this pull request as draft
October 27, 2026 21:06
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_files` mapping of environment variable name to a file whose content is the value for that variable. The repository rule reads the files at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict. Because the files are label inputs, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from `env` take precedence over `env_files`. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 21:07
c9060d6 to
2a955db
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 21:11
2a955db to
0e92745
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 21:14
0e92745 to
0e2526a
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 21:16
0e2526a to
42eb327
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 21:18
42eb327 to
a94bac1
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 21:20
a94bac1 to
10c3064
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 21:22
10c3064 to
b116aea
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 21:27
b116aea to
5db79af
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
2 times, most recently
from
October 27, 2026 21:35
435ed2d to
5db79af
Compare
acecilia
marked this pull request as ready for review
October 27, 2026 21:44
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 27, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 27, 2026 22:12
5db79af to
a9c8739
Compare
acecilia
added a commit
to acecilia/rules_ruby
that referenced
this pull request
Oct 28, 2026
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 28, 2026 13:00
a9c8739 to
6612528
Compare
Native gem extensions compile against arbitrary host system components, which rules_ruby must not enumerate (Xcode toolchains, pkg-config paths, compilers, ...). The static `env` attribute cannot express machine-resolved values, and `load()` is not allowed in MODULE.bazel, so values resolved by generated repositories cannot reach the generated rb_bundle_install action. Add an optional `env_file` label pointing to a file with KEY=VALUE lines. The repository rule reads it at evaluation time on the building machine and bakes the resolved values into the generated `env` as a plain static dict, so a consumer can compose the whole installation environment in a single dedicated repository rule. Because the file is a label input, content changes (e.g. a machine-resolved toolchain path changing) re-run the repository and change the install action key, keeping compiled native extensions correctly invalidated. Values from the static `env` take precedence for the same variable. Upstream: bazel-contrib#433
acecilia
force-pushed
the
feat/bundle-fetch-env-files
branch
from
October 29, 2026 11:07
6612528 to
0e53d06
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
rb_bundle_installcompiles native gem extensions (json, prism, ffi, ...) against arbitrary host system components. On macOSmkmfresolves clang and the SDK throughxcrun, but other bundles needCC,PKG_CONFIG_PATH,CMAKE, ... — the set of possible host dependencies is unbounded.Consumers that need to control these values today face two dead ends:
envtag attribute only accepts static strings.Solution
Optional
env_fileattribute on thebundle_fetchtag: a label pointing to a file withKEY=VALUElines. The repository rule reads the file at evaluation time on the building machine and bakes the resolved values into the generatedenvas a plain static dict — the generatedBUILDstays fully static, noload()of consumer starlark, no symbol conventions.The referenced file is produced by a single dedicated consumer repository rule that composes the whole installation environment (here one resolving the Xcode pinned by the project):
Because the file is a label input to the repository rule:
rb_bundle_installaction key, so compiled native extensions are correctly invalidated (Xcode bump → recompile),The mechanism is provider-agnostic: the consumer rule decides what the environment contains (
DEVELOPER_DIRtoday,PKG_CONFIG_PATHor a pinnedCCtomorrow), with rules_ruby baking in no system knowledge.Alternatives considered
repository_rule(environ = [...]): mirrors Bazel's native mechanism, but the variable list is a static per-rule declaration — a generic ruleset would need a hardcoded variable vocabulary, and values would depend on the ambient environment of the invocation.Testing
examples/gemexercisesenv_fileend-to-end:env_file_check_testasserts the value lands in the generated bundle repository (verified locally: passes with the correct value, fails with a tampered one), and the executedbundle_install_*.shcontainsexport RULES_RUBY_ENV_FILE_TEST=exercised. Also validated in a large consumer repo:DEVELOPER_DIRreaches the install script via ause_repo_rulerepository, and changing the file content re-runs the bundle install action.