Skip to content

Add an error for running jruby.sh from a broken JRUBY_HOME#9217

Merged
headius merged 1 commit intojruby:masterfrom
headius:better_broken_jruby_home_error
Feb 6, 2026
Merged

Add an error for running jruby.sh from a broken JRUBY_HOME#9217
headius merged 1 commit intojruby:masterfrom
headius:better_broken_jruby_home_error

Conversation

@headius
Copy link
Member

@headius headius commented Feb 5, 2026

In #9216 @eregon reported that JRuby was failing to run specs with an error about unbound variable JRUBY_CP. This variable can only be left unset if the bin/jruby.sh being executed is not accompanied by a sibling lib/jruby.jar, as might happen when running from a fresh repository clone.

The issue in #9216 was that for some reason, subprocesses launching ruby were choosing the bin scripts from a fresh JRuby clone rather than the one in PATH associated with a fully-functional JRuby.

This configuration is unsupported; bin/jruby.sh uses relative pathing to find its associated lib/jruby.jar, and if it is not present there's no way to proceed with execution. But the error message provided is cryptic and does not help a user debug the issue.

This path adds a check for the missing jar and terminates early with the following error message (negotiable):

[] jruby $ which ruby
/Users/headius/work/jruby/bin/ruby
[] jruby $ ls /Users/headius/work/jruby/lib/*.jar
zsh: no matches found: /Users/headius/work/jruby/lib/*.jar
[] jruby $ ruby -v
JRUBY_HOME at /Users/headius/work/jruby contains no lib/jruby.jar, exiting.
[] jruby $

If bin/jruby.sh is located within a JRUBY_HOME that is incomplete
(such as a freshly-checked-out repository) it will fail when it
tries to access an unset JRUBY_CP variable. This patch detects the
missing lib/jruby.jar and terminates the script early rather than
letting it fail with a cryptic shell error.

See jruby#9216
@headius
Copy link
Member Author

headius commented Feb 5, 2026

Ping @mrnoname1000 for a review.

@headius headius requested a review from mrnoname1000 February 5, 2026 21:23
@headius headius added this to the JRuby 10.0.4.0 milestone Feb 5, 2026
Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mrnoname1000 mrnoname1000 left a comment

Choose a reason for hiding this comment

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

Looks like a good change

@headius headius merged commit e8fe40d into jruby:master Feb 6, 2026
79 checks passed
@headius headius deleted the better_broken_jruby_home_error branch February 6, 2026 16:44
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.

3 participants