Repository navigation
fix: resolve rb_binary main scripts from any working directory - #427
Merged
p0deje merged 1 commit intoOct 26, 2026
Merged
Conversation
The launcher resolves main scripts in the main repository relative to the working directory, which only matches bazel run's default cwd. Invocations that change the cwd (e.g. bazel --run_under="cd ...", or running the launcher binary directly) fail with a LoadError. Locate these scripts through runfiles instead, falling back to the relative path so behavior under plain bazel run is unchanged. Windows behavior is unchanged.
acecilia
marked this pull request as ready for review
October 22, 2026 23:05
p0deje
approved these changes
Oct 26, 2026
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_binarylaunchers fail with aLoadErrorwhen they run with a working directory other than thebazel rundefault:This affects:
bazel run --run_under="cd ... &&" ...(e.g. wrappers that preserve the caller's cwd)Root cause
generate_rb_binary_scriptonly locates the main script through runfiles when it lives outside the main repository (../-prefixed short path). Mains in the main repository are baked into the launcher as raw relative paths, so they only resolve when the cwd matchesbazel run's default (<launcher>.runfiles/_main).Fix
Locate the main script through runfiles for non-Windows platforms regardless of repository, with a runtime fallback to the previous relative-path behavior:
rlocation, fails with a hint if missing)rlocation, falling back to the relative path when the lookup misses (e.g. a main not included in runfiles), so plainbazel runbehaves exactly as beforeRelated
LoadErrorwhenever therb_binarymain lives in the main repository.Testing
examples/gem:bazel run lib/gem:add-numbers 2— unchanged ✅/— previouslyLoadError, now prints3✅bazel run --run_under="cd / &&" lib/gem:add-numbers -- 2— now prints3✅examples-gem(non-Windows) exercising direct launcher invocation from a foreign cwdbazel run :buildifier.check✅bazel test --ignore_dev_dependency //ruby/tests:all✅ (7/7)Created with AI ✨ but reviewed thoroughly by me 👨💻