On 21.03.2007 11:48, vulpes wrote:
With this code, the temporary file in ./aDir will not be removed. Is
this a bug, a Cygwin/Windows “feature”, or what? How to get around
If you do this it will be removed (regardless whether you use chdir or
not) - at least that’s the behavior I observe on my system:
Tempfile.open(“johndoe”, “/tmp”) do |f|
# Can be even empty
Basically the chdir isn’t needed anyway. It appears you hit a bug in
the stdlib: it seems to try to delete “./” but fails
because the file does not exist (remember that “.” points to a different
I just had a quick check of the Tempfile code and it appears that no
attempts are made to get an absolute path. There is not a single
occurrence of expand_path in tempfile.rb.
The obvious workaround is to use an absolute path (see above).