Make pkg_install work without "runfiles" (Windows default)#984
Merged
tonyaiuto merged 1 commit intobazelbuild:mainfrom Nov 13, 2025
Merged
Conversation
424ea34 to
a8e9790
Compare
On Windows, `pkg_install` wouldn't work out of the box without passing
`--enable_runfiles` to Bazel:
```
windows> bazel run [redacted]//:install -- --destdir=d:\est
[...]
INFO: Running command line: [redacted]/install.exe <args omitted>
Traceback (most recent call last):
File "[redacted]\install_install_script.py", line 307, in <module>
sys.exit(main(sys.argv))
^^^^^^^^^^^^^^
File "[redacted]\install_install_script.py", line 299, in main
installer.include_manifest_path(f)
File "[redacted]\install_install_script.py", line 182, in include_manifest_path
with open(path, 'r') as fh:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '../[redacted]/install_install_script-install-manifest.json'
```
In order to accomodate the various use cases (`build`, `test` and `run`
actions; enabled and disabled runfiles), the present change proposes to
leverage `rules_python`'s "runfiles" lookup library:
https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html
For good measure, the change also enables
`bazel test //tests/install/...` in CI for Windows.
This might close bazelbuild#387.
a8e9790 to
57f4b7d
Compare
pkg_install work without runfiles (Windows default)pkg_install work without "runfiles" (Windows default)
cgrindel
approved these changes
Nov 8, 2025
Collaborator
cgrindel
left a comment
There was a problem hiding this comment.
Looks reasonable to me. I will wait to merge so that @tonyaiuto can take a look.
tonyaiuto
approved these changes
Nov 13, 2025
rdesgroppes
added a commit
to rdesgroppes/rules_pkg
that referenced
this pull request
Feb 5, 2026
When a `pkg_install` rule in an external repository references files from another repository, the installer would fail at runtime by attempting to resolve all files relative to its repository rather than each file's source repository. Example failure (`extrepo`: external repository installing file from main repository): ``` bazel run @extrepo//:install -- --destdir=/tmp/test [...] FileNotFoundError: [Errno 2] No such file or directory: '.../runfiles/+_repo_rules+extrepo/some-path/extrepo/file-in-main' ``` The file should be resolved against the main repository (`_main`) but is incorrectly looked up from the installer's repository runfiles (`+_repo_rules+extrepo`). The solution proposed here consists in extending the manifest to track each file's source repository and use this information during installation to resolve files against the correct repository. It adds a `repository` field to manifest entries using: - `Label.repo_name` ([canonical](https://bazel.build/rules/lib/builtins/Label#repo_name)) when available for the source file, - otherwise `ctx.workspace_name` when no [owner](https://bazel.build/rules/lib/builtins/File#owner) or `Label.repo_name` is [empty](https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html#runfiles.runfiles.Runfiles.CurrentRepository). Testing: - `//tests/install:install_test` includes new `CrossRepoInstallTest`, - real-world validation: `bazel run @extrepo//:install` successfully, - verified both on Ubuntu Linux and Windows as well. tl;dr: this change builds on bazelbuild#984 which introduced the `locate()` helper and the `runfiles` infrastructure. That PR fixed Windows compatibility by enabling runfiles-less operation; this change extends it to support files from external repositories.
rdesgroppes
added a commit
to rdesgroppes/rules_pkg
that referenced
this pull request
Feb 5, 2026
When a `pkg_install` rule in an external repository references files from another repository, the installer would fail at runtime by attempting to resolve all files relative to its repository rather than each file's own repository. Example failure (`extrepo`: external repository installing file from main repository): ``` bazel run @extrepo//:install -- --destdir=/tmp/test [...] FileNotFoundError: [Errno 2] No such file or directory: '.../runfiles/+_repo_rules+extrepo/some-path/extrepo/file-in-main' ``` The file should be resolved against the main repository (`_main`) but is incorrectly looked up from the installer's repository runfiles (`+_repo_rules+extrepo`). The solution proposed here consists in extending the manifest to track each file's source repository and use this information during installation to resolve files against the correct repository. It adds a `repository` field to manifest entries using: - `Label.repo_name` ([canonical](https://bazel.build/rules/lib/builtins/Label#repo_name)) when available for the source file, - otherwise `ctx.workspace_name` when no [owner](https://bazel.build/rules/lib/builtins/File#owner) or `Label.repo_name` is [empty](https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html#runfiles.runfiles.Runfiles.CurrentRepository). Testing: - `//tests/install:install_test` includes new `CrossRepoInstallTest`, - real-world validation: `bazel run @extrepo//:install` successfully, - verified both on Ubuntu Linux and Windows as well. tl;dr: this change builds on bazelbuild#984 which introduced the `locate()` helper and the `runfiles` infrastructure. That PR fixed Windows compatibility by enabling runfiles-less operation; this change extends it to support files from external repositories.
rdesgroppes
added a commit
to rdesgroppes/rules_pkg
that referenced
this pull request
Feb 5, 2026
When a `pkg_install` rule in an external repository references files from another repository, the installer would fail at runtime by attempting to resolve all files relative to its repository rather than each file's own repository. Example failure (`extrepo`: external repository installing file from main repository): ``` bazel run @extrepo//:install -- --destdir=/tmp/test [...] FileNotFoundError: [Errno 2] No such file or directory: '.../runfiles/+_repo_rules+extrepo/some-path/extrepo/file-in-main' ``` The file should be resolved against the main repository (`_main`) but is incorrectly looked up from the installer's repository runfiles (`+_repo_rules+extrepo`). The solution proposed here consists in extending the manifest to track each file's own repository and use this information during installation to resolve files against the correct repository. It adds a `repository` field to manifest entries using: - `Label.repo_name` ([canonical](https://bazel.build/rules/lib/builtins/Label#repo_name)) when available for the source file, - otherwise `ctx.workspace_name` when no [owner](https://bazel.build/rules/lib/builtins/File#owner) or `Label.repo_name` is [empty](https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html#runfiles.runfiles.Runfiles.CurrentRepository). Testing: - `//tests/install:install_test` includes new `CrossRepoInstallTest`, - real-world validation: `bazel run @extrepo//:install` successfully, - verified both on Ubuntu Linux and Windows as well. tl;dr: this change builds on bazelbuild#984 which introduced the `locate()` helper and the `runfiles` infrastructure. That PR fixed Windows compatibility by enabling runfiles-less operation; this change extends it to support files from external repositories.
rdesgroppes
added a commit
to rdesgroppes/rules_pkg
that referenced
this pull request
Feb 6, 2026
tl;dr: this change builds on bazelbuild#984 which introduced the `locate()` helper and the `runfiles` infrastructure. That PR fixed Windows compatibility by enabling runfiles-less operation; this change extends it to support files from cross-repository runfiles. When a `pkg_install` rule in an external repository references files from another repository, the installer would fail at runtime by attempting to resolve all files relative to its repository rather than each file's own repository. Example failure (`extrepo`: external repository installing file from main repository): ``` bazel run @extrepo//:install -- --destdir=/tmp/test [...] FileNotFoundError: [Errno 2] No such file or directory: '.../runfiles/+_repo_rules+extrepo/some-path/extrepo/file-in-main-repo' ``` The file should be resolved against the main repository (`_main`) but is incorrectly looked up from the installer's repository runfiles (`+_repo_rules+extrepo`). The solution proposed here consists in extending the manifest to track each file's own repository and use this information during installation to resolve files against the correct repository runfiles. It adds a `repository` field to manifest entries using: - `Label.repo_name` ([canonical](https://bazel.build/rules/lib/builtins/Label#repo_name)) when explicitly valued for the source file, - otherwise `ctx.workspace_name` when no [owner](https://bazel.build/rules/lib/builtins/File#owner) or `Label.repo_name` is [empty](https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html#runfiles.runfiles.Runfiles.CurrentRepository), denoting the main repository ("_main", as before). Testing: - `//tests/install:install_test` includes new `CrossRepoInstallTest`, - `bazel run @extrepo//:install -- --destdir=/tmp/test` succeeds, - verified the above on Ubuntu Linux and Windows as well.
rdesgroppes
added a commit
to rdesgroppes/rules_pkg
that referenced
this pull request
Feb 6, 2026
tl;dr: this change builds on bazelbuild#984 which introduced the `locate()` helper and the `runfiles` infrastructure. That PR fixed Windows compatibility by enabling runfiles-less operation; this change extends it to support cross-repository files. When a `pkg_install` rule in an external repository references files from another repository, the installer would fail at runtime by attempting to resolve all files relative to its repository rather than each file's own repository. Example failure (`extrepo`: external repository installing file from main repository): ``` bazel run @extrepo//:install -- --destdir=/tmp/test [...] FileNotFoundError: [Errno 2] No such file or directory: '.../runfiles/+_repo_rules+extrepo/some-path/extrepo/file-in-main-repo' ``` The file should be resolved against the main repository (`_main`) but is incorrectly looked up from the installer's repository (`+_repo_rules+extrepo`). The solution proposed here consists in extending the manifest to track each file's own repository and use this information during installation to resolve files against the correct repository. It adds a `repository` field to manifest entries using: - `Label.repo_name` ([canonical](https://bazel.build/rules/lib/builtins/Label#repo_name)) when explicitly valued for the source file, - otherwise `ctx.workspace_name` when no [owner](https://bazel.build/rules/lib/builtins/File#owner) or `Label.repo_name` is [empty](https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html#runfiles.runfiles.Runfiles.CurrentRepository), denoting the main repository ("_main", as before). Testing: - `//tests/install:install_test` includes new `CrossRepoInstallTest`, - `bazel run @extrepo//:install -- --destdir=/tmp/test` would succeed, - verified the above on Ubuntu Linux and Windows as well.
rdesgroppes
added a commit
to rdesgroppes/rules_pkg
that referenced
this pull request
Feb 6, 2026
tl;dr: this change builds on bazelbuild#984 which introduced the `locate()` helper and the `runfiles` infrastructure. That PR fixed Windows compatibility by enabling runfiles-less operation; this change extends it to support cross-repository files. When a `pkg_install` rule in an external repository references files from another repository, the installer would fail at runtime by attempting to resolve all files relative to its repository rather than each file's own repository. Example failure (`extrepo`: external repository installing file from main repository): ``` bazel run @extrepo//:install -- --destdir=/tmp/test [...] FileNotFoundError: [Errno 2] No such file or directory: '.../runfiles/+_repo_rules+extrepo/some-path/extrepo/file-in-main-repo' ``` The file should be resolved against the main repository (`_main`) but is incorrectly looked up from the installer's repository (`+_repo_rules+extrepo`). The solution proposed here consists in extending the manifest to track each file's own repository and use this information during installation to resolve files against the correct repository. It adds a `repository` field to manifest entries using: - `Label.repo_name` ([canonical](https://bazel.build/rules/lib/builtins/Label#repo_name)) when explicitly valued for the source file, - otherwise `ctx.workspace_name` when no [owner](https://bazel.build/rules/lib/builtins/File#owner) or `Label.repo_name` is [empty](https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html#runfiles.runfiles.Runfiles.CurrentRepository), denoting the main repository (`_main`, as before). Testing: - `//tests/install:install_test` includes new `CrossRepoInstallTest`, - `bazel run @extrepo//:install -- --destdir=/tmp/test` case works, - verified the above on Ubuntu Linux and Windows as well.
rdesgroppes
added a commit
to rdesgroppes/rules_pkg
that referenced
this pull request
Feb 8, 2026
tl;dr: this change builds on bazelbuild#984 which introduced the `locate()` helper and the `runfiles` infrastructure. That PR fixed Windows compatibility by enabling runfiles-less operation; this change extends it to support cross-repository files. When a `pkg_install` rule in an external repository references files from another repository, the installer would fail at runtime by attempting to resolve all files relative to its repository rather than each file's own repository. Example failure (`extrepo`: external repository installing file from main repository): ``` bazel run @extrepo//:install -- --destdir=/tmp/test [...] FileNotFoundError: [Errno 2] No such file or directory: '.../runfiles/+_repo_rules+extrepo/some-path/extrepo/file-in-main-repo' ``` The file should be resolved against the main repository (`_main`) but is incorrectly looked up from the installer's repository (`+_repo_rules+extrepo`). The solution proposed here consists in extending the manifest to track each file's own repository and use this information during installation to resolve files against the correct repository. It adds a `repository` field to manifest entries using: - `Label.repo_name` ([canonical](https://bazel.build/rules/lib/builtins/Label#repo_name)) when explicitly valued for the source file, - otherwise `ctx.workspace_name` when no [owner](https://bazel.build/rules/lib/builtins/File#owner) or `Label.repo_name` is [empty](https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html#runfiles.runfiles.Runfiles.CurrentRepository), denoting the main repository (`_main`, as before). Testing: - `//tests/install:install_test` includes new `CrossRepoInstallTest`, - `bazel run @extrepo//:install -- --destdir=/tmp/test` case works, - verified the above on Ubuntu Linux and Windows as well.
aiuto
pushed a commit
that referenced
this pull request
Feb 10, 2026
tl;dr: this change builds on #984 which introduced the `locate()` helper and the `runfiles` infrastructure. That PR fixed Windows compatibility by enabling runfiles-less operation; this change extends it to support cross-repository files. When a `pkg_install` rule in an external repository references files from another repository, the installer would fail at runtime by attempting to resolve all files relative to its repository rather than each file's own repository. Example failure (`extrepo`: external repository installing file from main repository): ``` bazel run @extrepo//:install -- --destdir=/tmp/test [...] FileNotFoundError: [Errno 2] No such file or directory: '.../runfiles/+_repo_rules+extrepo/some-path/extrepo/file-in-main-repo' ``` The file should be resolved against the main repository (`_main`) but is incorrectly looked up from the installer's repository (`+_repo_rules+extrepo`). The solution proposed here consists in extending the manifest to track each file's own repository and use this information during installation to resolve files against the correct repository. It adds a `repository` field to manifest entries using: - `Label.repo_name` ([canonical](https://bazel.build/rules/lib/builtins/Label#repo_name)) when explicitly valued for the source file, - otherwise `ctx.workspace_name` when no [owner](https://bazel.build/rules/lib/builtins/File#owner) or `Label.repo_name` is [empty](https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.html#runfiles.runfiles.Runfiles.CurrentRepository), denoting the main repository (`_main`, as before). Testing: - `//tests/install:install_test` includes new `CrossRepoInstallTest`, - `bazel run @extrepo//:install -- --destdir=/tmp/test` case works, - verified the above on Ubuntu Linux and Windows as well.
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.
On Windows,
pkg_installwouldn't work out of the box without passing--enable_runfilesto Bazel:In order to accomodate the various use cases (
build,testandrunactions; enabled and disabled runfiles), the present change proposes to leveragerules_python's "runfiles" lookup library: https://rules-python.readthedocs.io/en/latest/api/py/runfiles/runfiles.runfiles.htmlFor good measure, the change also enables
bazel test //tests/install/...in CI for Windows.This might close #387.