Skip to content

fix: include the toolchain interpreter in rb_gem_push runfiles - #409

Merged
p0deje merged 4 commits into
bazel-contrib:mainfrom
titusfortner:c/rules-ruby-gem-push-runfiles-498a01
Oct 6, 2026
Merged

p0deje merged 4 commits into
bazel-contrib:mainfrom
titusfortner:c/rules-ruby-gem-push-runfiles-498a01

Conversation

@titusfortner

Copy link
Copy Markdown
Contributor

Problem

  • rb_gem_push only adds the toolchain's gem script and the .gem file to its runfiles, so the generated wrapper's rlocation of the interpreter comes up empty and the final exec ruby|jruby gem push ... falls back to whatever is on PATH. With MRI this is masked by a system Ruby on most machines; with JRuby it fails outright:
dirname: missing operand
bazel-out/k8-opt/bin/rb/selenium-webdriver-release-nightly.sh: line 104: exec: jruby: not found
  • The rule also skips the toolchain env (TruffleRuby's OPENSSL_PREFIX and LANG, JRuby's Windows JAVA_OPTS) and only applies the target's env through RunEnvironmentInfo, so the documented $(location) expansion never runs and the generated script only works under bazel run.

Seen in the SeleniumHQ/selenium nightly release: https://github.com/SeleniumHQ/selenium/actions/runs/35165684730

Solution

  • Mirror rb_binary: put toolchain.files in runfiles, pass java_bin so JAVA_HOME resolves from runfiles under JRuby, merge toolchain.env, and bake the env into the generated script.
  • Add bazel run :gem-release -- --help to the examples/gem CI matrix. It fails on every JRuby entry without this change.

Verified in Selenium with the runfiles part applied as a patch: https://github.com/SeleniumHQ/selenium/actions/runs/35171062663/job/105043434920

@p0deje p0deje left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@titusfortner Can you check what's wrong with CI?

@titusfortner
titusfortner force-pushed the c/rules-ruby-gem-push-runfiles-498a01 branch from a237b63 to 42a1c7a Compare October 6, 2026 18:50
@titusfortner

titusfortner commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

The Windows failures were two pre-existing rb_gem_push bugs that the new bazel run :gem-release CI step surfaced.

  • the batch wrapper unconditionally calls rlocation with {runfiles_helper}, which rb_gem_push never supplied, so every Windows job exited with "Expected two arguments for rlocation function" before gem ran. Fixed by wiring the runfiles helper into rb_gem_push the same way rb_binary does.
  • JRuby's jgem.cmd is a plain batch file, so jruby.exe jgem.cmd fails to parse. MRI only works because Ruby's gem.cmd is a polyglot that is valid Ruby, so the fix bypasses the interpreter for JRuby .cmd stubs only.

@titusfortner
titusfortner requested a review from p0deje October 6, 2026 19:19
@p0deje
p0deje merged commit e753825 into bazel-contrib:main Oct 6, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants