Skip to content

JRuby debugging support or documentation #314

@noahkawasakigoogle

Description

@noahkawasakigoogle

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:

  1. Use --run_under with extra jruby args --debug -S rdebug as 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.

  1. Directly use pry or pry-remote in source file and use bazel run instead of bazel 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions