Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO.popen cannot run 'date' on Windows 7 #2505

Closed
kingspider1971 opened this issue Jan 23, 2015 · 3 comments
Closed

IO.popen cannot run 'date' on Windows 7 #2505

kingspider1971 opened this issue Jan 23, 2015 · 3 comments

Comments

@kingspider1971
Copy link

dateProc = IO.popen("date", 'w+')
dateProc.puts "\n"
dateProc.close_write
s2 = dateProc.gets
puts s2

Execution Result:
D:\ruby\jruby-1.7.18\bin\jruby.exe --1.9 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) D:/ruby/projects/test1/test/test1.rb
IOError: Cannot run program "date" (in directory "D:\ruby\projects\test1\test"): CreateProcess error=2, ?????????
popen at org/jruby/RubyIO.java:4345
(root) at D:/ruby/projects/test1/test/test1.rb:1
load at org/jruby/RubyKernel.java:1087
(root) at -e:1

@headius
Copy link
Member

headius commented Feb 24, 2015

This works ok in 9k. I believe the "date" command is not an executable but a cmd.exe subcommand. 9k must be handling that and 1.7 is not.

@headius
Copy link
Member

headius commented Feb 24, 2015

Nevermind, it turns out I had a date.exe in the path for 9k. We are not handling this right on either branch.

@headius
Copy link
Member

headius commented Feb 24, 2015

Ok, so it turns out we had the right logic for non-popen spawns (system, backticks) and I was able to add it to popen. It's probably not the cleanest fix but it appears to work right.

Should be fixed in 1.7.20 and 9k.pre2.

@headius headius closed this as completed Feb 24, 2015
headius added a commit that referenced this issue Feb 27, 2015
It is not clear whether popen should automatically choose sh when
under *nix, and this causes test_pid in MRI test_io to fail with
an off-by-one pid (because the sh process and the target command
are different pids).
@enebo enebo added this to the 9.0.0.0.pre2 milestone Apr 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants