Hi folks.
How does one robustly refer to another repository when using rlocation in bash scripts?
Consider this example:
readonly _run_this="$(rlocation runfiles~/binary)"
this shell snippet refers to the location of the target called binary in a dep repo called @runfiles.
How does one do this in a robust way? To wit the “apparent” name runfiles~ is an implementation detail of bazel 7.x. If I upgrade to bazel 8.x, this will become an error as the "correct" name is now `runfiles+`.
Where this becomes a problem, is when we don’t know what bazel version will be used to compile this code. Ostensibly, both 7.x and 8.x should work. But in this case, the script becomes brittle, as one would expect given that it's relying on an implementation detail to resolve rlocation. I usually solve this in my code by pinning the bazel version. But this might not be an option when offering a module to an unknown user.
What’s the canonical solution to this? Resolving the current repository is handled using the runfiles_current_repository function. What about “non-current” repository?
F
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bazel-discuss/CAKaOXigbjKENnu2NQtPzs54a70XXrfYqctLYuF97vnakdWMewQ%40mail.gmail.com.