-
Notifications
You must be signed in to change notification settings - Fork 13
Description
On MRI Ruby (3.4.5) and JRuby (non-Windows) :chdir is allowed to be a Pathname, however this does not work on JRuby Windows with the custom logic here.
ruby -r open3 -r pathname -e "out, err, status = Open3.capture3('pwd', :chdir => Pathname.new('.')); p out"Expected Behaviour
MacOS JRuby 9.4:
$ ruby -v
jruby 9.4.14.0 (3.1.7) 2025-08-28 ddda6d5992 OpenJDK 64-Bit Server VM 21.0.8+9-LTS on 21.0.8+9-LTS +jit [arm64-darwin]
$ ruby -r open3 -r pathname -e "out, err, status = Open3.capture3('pwd', :chdir => Pathname.new('.')); p out"
"/Users/chad/Projects/community\n"
MacOS MRI Ruby 3.4.5:
$ ruby -v
ruby 3.4.5 (2025-07-16 revision 20cda200d3) +PRISM [arm64-darwin24]
$ ruby -r open3 -r pathname -e "out, err, status = Open3.capture3('pwd', :chdir => Pathname.new('.')); p out"
"/Users/chad/Projects/community\n"
Actual behaviour
Windows JRuby 9.4 and 10.0
PS C:\community> ruby -v
jruby 9.4.14.0 (3.1.7) 2025-08-28 ddda6d5992 OpenJDK 64-Bit Server VM 21.0.3+9-LTS on 21.0.3+9-LTS +jit [aarch64-mswin32]
PS C:\community> ruby -r open3 -r pathname -e "out, err, status = Open3.capture3('pwd', :chdir => Pathname.new('.')); p out"
NameError: no constructor for arguments (org.jruby.ext.pathname.RubyPathname) on Java::JavaIo::File
available overloads:
(java.lang.String)
(java.net.URI)
new at org/jruby/RubyClass.java:923
processbuilder_run at C:/jruby-9.4.14.0/lib/ruby/stdlib/open3/jruby_windows.rb:81
popen3 at C:/jruby-9.4.14.0/lib/ruby/stdlib/open3/jruby_windows.rb:19
capture3 at C:/jruby-9.4.14.0/lib/ruby/stdlib/open3.rb:290
<main> at -e:1
PS C:\community> ruby -v
jruby 10.0.2.0 (3.4.2) 2025-08-07 cba6031bd0 OpenJDK 64-Bit Server VM 21.0.3+9-LTS on 21.0.3+9-LTS +indy +jit [aarch64-mswin32]
PS C:\community> ruby -r open3 -r pathname -e "out, err, status = Open3.capture3('pwd', :chdir => Pathname.new('.')); p out"
NameError: no constructor for arguments (org.jruby.ext.pathname.RubyPathname) on Java::JavaIo::File
available overloads:
(java.lang.String)
(java.net.URI)
new at org/jruby/RubyClass.java:1023
processbuilder_run at C:/jruby-10.0.2.0/lib/ruby/stdlib/open3/jruby_windows.rb:81
popen3 at C:/jruby-10.0.2.0/lib/ruby/stdlib/open3/jruby_windows.rb:19
capture3 at C:/jruby-10.0.2.0/lib/ruby/stdlib/open3.rb:658
<main> at -e:1
Additional Context
I'm not sure what the relationship is with https://github.com/jruby/jruby/blob/18a67190e1096d75e485945da789292cd03100eb/lib/ruby/stdlib/jruby/open3_windows.rb#L81 but that one has a similar problem, if it is indeed used.
It looks like @headius might be aware of this based on adding tests to ruby/spec recently? ruby/spec@614d1c3
https://docs.ruby-lang.org/en/master/Process.html#module-Process-label-Execution+Options does not explicitly seem to document what types are accepted, and the examples are strings, but I suppose ruby/spec is valid enough.