Thanks to visit codestin.com
Credit goes to github.com

Skip to content

When extension is omitted, IO.popen does not find the executable in JRuby on Windows #6516

@jcouball

Description

@jcouball

Environment Information

JRuby version and operating system:

  • jruby 9.2.14.0 (2.5.7) 2020-12-08 ebe64ba OpenJDK 64-Bit Server VM 25.275-b01 on 1.8.0_275-b01 +jit [mswin32-x86_64]
  • jruby 9.3.0.0-SNAPSHOT (2.6.5) 2020-12-28 0864236 OpenJDK 64-Bit Server VM 25.275-b01 on 1.8.0_275-b01 +jit [mswin32-x86_64]

Other relevant info:

Expected Behavior

GIVEN the following Ruby code running in JRuby on Windows

AND the following statement succeeds:

output = IO.popen(["gem.bat", "build", "-V", "jruby_test.gemspec"], &:read)

AND the PATHEXT environment variable is set to .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL

Then following statement (which omits the ".bat" extension) should also succeed:

output = IO.popen(["gem", "build", "-V", "jruby_test.gemspec"], &:read)

I noticed this in my CI job for my gem. I do not have a windows box to test this on, but was able to duplicate this using GitHub Actions using a Windows VM:

https://github.com/jcouball/jruby_test/blob/main/Rakefile#L7

In JRuby on Windows, the popen_test_1 rake task succeeds and the popen_test_2 rake task fails.

Actual Behavior

The second command fails with the error:

IOError: Cannot run program "gem" (in directory "D:\a\jruby_test\jruby_test"): CreateProcess error=2, The system cannot find the file specified

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions