oneclick / rubyinstaller2

MSYS2 based RubyInstaller for Windows
https://rubyinstaller.org
BSD 3-Clause "New" or "Revised" License
645 stars 248 forks source link

system calls that pipe to /dev/null fail with "The system cannot find the path specified." #323

Closed gfody closed 1 year ago

gfody commented 1 year ago

I'm not sure if this is actually a rubyinstaller or msys problem, as you could code specifically for windows with > nul instead of > /dev/null but ideally this would work as-is..

What problems are you experiencing?

Working with ruby code that makes a lot of system calls with the output piped to /dev/null on Windows it's executing something like:

sh -c echo asdf > /dev/null
The system cannot find the path specified.

as a workaround I can create a file at C:\dev\null but it seems like there could be a better way?

Steps to reproduce

irb(main):001:0> `echo asdf > /dev/null`
The system cannot find the path specified.
=> ""
irb(main):002:0> system("echo asdf > /dev/null")
The system cannot find the path specified.
=> false

What's the output from ridk version?

I'm using vanilla msys2 and installed ruby from ci.ri2/mingw-w64-x86_64-ruby27 2.7.7-1

larskanis commented 1 year ago

/dev/null is only valid in an MSYS2 application. But all MINGW applications are native Windows, so that only NUL is valid. Similar, if you shell out from ruby, the echo command of CMD is executed, which is a native Windows application as well.

In ruby there is a constant for the null device of the running platform. It is File::NULL or so. Can't test right now...

gfody commented 1 year ago

ah that make sense, so for this project I should try an msys build of ruby instead of mingw (or I can try to make the code more portable w/File::NULL) - thanks!