Cannot move a Tempfile after creation
-------------------------------------

                 Key: JRUBY-3843
                 URL: http://jira.codehaus.org/browse/JRUBY-3843
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.3.1
         Environment: becherovka:~% uname -a
Darwin becherovka.local 9.7.0 Darwin Kernel Version 9.7.0: Tue Mar 31 22:52:17 
PDT 2009; root:xnu-1228.12.14~1/RELEASE_I386 i386
becherovka:~% jruby -v
jruby 1.3.1 (ruby 1.8.6p287) (2009-07-28 6586) (Java HotSpot(TM) 64-Bit Server 
VM 1.6.0_13) [x86_64-java]
            Reporter: Otto Hilska


Given the following test code:

require 'fileutils'
require 'tempfile'

# Creating a normal file and then moving it to a new path.
normal = File.new("testing-normal-file", "w")
normal.write "Hello world"
normal.close

FileUtils.mv(normal.path, "final-destination-for-normal")
FileUtils.rm("final-destination-for-normal")

# Creating a temp file and then moving it to a new path (FAILS).
temp = Tempfile.new("testing-temp-file")
temp.write "Hello world"
temp.close

FileUtils.mv(temp.path, "final-destination-for-temp")
FileUtils.rm("final-destination-for-temp")

Ruby 1.8.6 vs. JRuby 1.3.1 I get the following error:

becherovka:jruby-patch% jruby test-tempfile-works.rb 
/opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:505:in `mv': Permission 
denied - Permission denied - 
/var/folders/FM/FM14TWZOGTO5+zRtKGjKhE+++TI/-Tmp-/testing-temp-file.68114.21759 
or final-destination-for-temp (Errno::EACCES)
        from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1395:in 
`fu_each_src_dest'
        from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1411:in 
`fu_each_src_dest0'
        from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1393:in 
`fu_each_src_dest'
        from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:494:in `mv'
        from test-tempfile-works.rb:17
becherovka:jruby-patch% ruby test-tempfile-works.rb 
becherovka:jruby-patch%

I think this is quite major, because I can't use buildr because of this problem.

There's something funny about the reproducibility of this problem. I don't know 
if it's about the OS X version or what, but I can't reproduce the problem with 
our iMacs and older MacBook Pros, but it is broken with unibody MacBook Pros 
and Mac Minis. :)

It's not about file permissions either. I can give an additional parameter to 
Tempfile creation to change the tempdir, but the problem stays:

becherovka:jruby-patch% jruby test-tempfile-works.rb 
/opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:505:in `mv': Permission 
denied - Permission denied - /tmp/testing-temp-file.68172.18957 or 
final-destination-for-temp (Errno::EACCES)
        from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1395:in 
`fu_each_src_dest'
        from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1411:in 
`fu_each_src_dest0'
        from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1393:in 
`fu_each_src_dest'
        from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:494:in `mv'
        from test-tempfile-works.rb:17

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to