-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Filing an issue track and discuss JRuby debugging either interactively with a gem like pry or with a remote client as suggested in known issues.
bazel version: bazel 7.1.0- (@non-git)
Jruby version: jruby 9.4.13.0 (3.1.4) 2025-06-10 9938a3461f OpenJDK 64-Bit Server VM 11.0.23+0-adhoc..source on 11.0.23+0-adhoc..source +jit [x86_64-linux]
My attempts to get interactive JRuby debugging with bazel so far have not worked and I am wondering if anyone else has had any success. Either a simple pry session or a remote client would be great, so far I have not found any solution.
Attempts:
- Use
--run_underwith extra jruby args--debug -S rdebugas recommended on JRuby docs.
# .bazelrc
test:rdebug --run_under="@ruby//:ruby --debug -S rdebug"
run:rdebug --run_under="@ruby//:ruby --debug -S rdebug"
> bazel run --config rdebug //...
SyntaxError in /usr/local/google/home/noahkawasaki/.cache/bazel/_bazel_noahkawasaki/609538bf8d377998d87a9e47c9eb3c34/execroot/helltool/bazel-out/k8-fastbuild/bin/ruby-gems/ht_java/test_ht_java_test_rb.sh.runfiles/helltool/ruby-gems/ht_java/test_ht_java_test_rb.sh:5: syntax error, unexpected local variable or method
set -uo pipefail; f=bazel_tools/tools/bash/run...
^~~~~~~~
I believe this fails because rb_binary and rb_test produce a shell script as the executable, and jruby --debug -S rdebug obviously cannot execute a shell script.
- Directly use
pryorpry-remotein source file and usebazel runinstead ofbazel test, which supposedly allows STDIN access as a workaround.
In ruby file:
require 'pry'
require 'pry-remote'
# anywhere in test file
binding.pry
binding.remote_pry
> bazel run //...
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //ruby-gems/ht_java:test_ht_java_test_rb
-----------------------------------------------------------------------------
Picked up JAVA_TOOL_OPTIONS: -Dcalcite.enable.collation.trait=false -Dcdjd.io.netty.tryReflectionSetAccessible=true -Dnashorn.args="--optimistic-types=false" -Dnashorn.propmap.queue.threshold=5000 -Djava.library.path=/nix/store/kpy2cyd05vdr6j1h200av81fnlxl1jw0-glibc-2.39-52/lib
Picked up JAVA_TOOL_OPTIONS: -Dcalcite.enable.collation.trait=false -Dcdjd.io.netty.tryReflectionSetAccessible=true -Dnashorn.args="--optimistic-types=false" -Dnashorn.propmap.queue.threshold=5000 -Djava.library.path=/nix/store/kpy2cyd05vdr6j1h200av81fnlxl1jw0-glibc-2.39-52/lib
Started with run options --seed 51274
SomeTest
test_xxx SKIP (2.14s)
# hangs here and nothing else happens
In this case, it appears the binding.pry is successfully halting the program, however there is no ability to interact with pry session.