Forum: Ruby File.utime returns Invalid argument on Windows (winXP, ruby

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
5ef84138e0a7b0b577ab28ee80df9143?d=identicon&s=25 Matt Scilipoti (Guest)
on 2007-06-05 19:55
(Received via mailing list)
I am receiving an "Invalid argument" error from File.utime.

irb> testfile = 'd:/temp/2007/06/test.txt'
=> "d:/temp/2007/06/test.txt"
irb> File.utime(0,, testfile)
Errno::EINVAL: Invalid argument - d:/temp/2007/06/test.txt
        from (irb):4:in `utime'
        from (irb):4
irb> File.exist?(testfile)
=> true
irb> File.writable?(testfile)
=> true

My local user group suggested:
irb> require 'time'
=> false


I tried this on two computers:
| WinXP SP2 | WinXP SP2 |
| Ruby 1.8.6  | 1.8.5 |
| NTFS         | FAT32 |

A friend has these same specs, but it works for him.
Google for 'ruby, windows, File.utime, "Invalid Argument"' (and various
of this) doesn't help.  It does appear in a nice Ruby poetry jam.

Any ideas?
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (Guest)
on 2007-06-06 16:36
(Received via mailing list)
On Jun 5, 11:55 am, "Matt Scilipoti" <>
> irb> File.writable?(testfile)
> => true

Is D: a hard disk? Or is it a CDROM, usb drive, etc? Hey, gotta ask.

> My local user group suggested:
> irb> require 'time'
> => false
> False?

Unrelated. It means it was already loaded, probably by rubygems. An
actual failure would raise an error.


5ef84138e0a7b0b577ab28ee80df9143?d=identicon&s=25 Matt Scilipoti (Guest)
on 2007-06-06 16:59
(Received via mailing list)
Solved (mostly), thanks to:

Nicholas Evans, who suggested that Windows may not accept a date of 0
(the first param sets access time).  It doesn't.  I knew that.  Bad
brain.  Thanks for asking an "is it plugged in" type of question.

Daniel Berger, for reminding me that "require 'x' -> false" doesn't
mean "we can't find 'x'" - it just means that it is ALREADY required.
I knew that too.  Funny how, in this context, I easily accepted an
incorrect translation of the results, because it was corroborating
evidence - exactly what I was looking for.  And thanks for another "is
it plugged in?" question.  Yes, D: drive is a hard drive.  :)

Why "mostly"?  This code is derived from a battery of tests for a
project in a User Group.  These tests pass for another Windows user.
We will investigate next meeting.

Thanks to all,
This topic is locked and can not be replied to.