Skip to content

Dir.home is no longer compatible with CRuby after JRuby 9.3 #7735

@h-r-k-matsumoto

Description

@h-r-k-matsumoto

Environment Information

JRuby version:
jruby 9.4.2.0 (3.1.0) 2023-03-08 90d2913 OpenJDK 64-Bit Server VM 25.362-b09 on 1.8.0_362-b09 +jit [x86_64-linux]

Operating system and platform:
Linux 96d20f512b68 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

I use docker images jruby:9.4 and jruby:9.3

Expected Behavior

Dir.home with nil returns home directory of current user.
I expect JRuby to be the same behavior.

$ docker run -it --rm ruby:3.2
irb(main):001:0> Dir.home nil
=> "/root"
irb(main):002:0>

https://ruby-doc.org/3.2.1/Dir.html#method-c-home

Actual Behavior

After JRuby 9.3, Dir.home returns an error if user is nil.

$ docker run -it --rm jruby:9.4
irb(main):001:0> Dir.home nil
org/jruby/RubyDir.java:635:in `home': no implicit conversion of nil into String (TypeError)
	from (irb):1:in `evaluate'
	from org/jruby/RubyKernel.java:1143:in `eval'
	from org/jruby/RubyKernel.java:1586:in `loop'
	from org/jruby/RubyKernel.java:1292:in `catch'
	from org/jruby/RubyKernel.java:1292:in `catch'
	from /opt/jruby/lib/ruby/gems/shared/gems/irb-1.4.2/exe/irb:11:in `<main>'
	from org/jruby/RubyKernel.java:1091:in `load'
	from /opt/jruby/bin/irb:23:in `<main>'
irb(main):002:0>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions