Open3 on JRuby Windows does not support `Pathname` in `options[:chdir]`
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 121
- Forks
- 14
- Avg merge
- 17m
- Merged PRs (30d)
- 2
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? https://github.com/ruby/spec/commit/614d1c31f43cd59572d02c83ba51306a5e4c4dd4
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/ruby/stdlib/jruby_windows.rb at processbuilder_run, then compare the related jruby/open3_windows.rb implementation linked in the issue. Run the provided Windows JRuby command with Pathname.new('.') and verify that the chdir option works without the Java File constructor error, with regression coverage informed by the referenced ruby/spec change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100