FileUtils#cp (ultimately FileStat.identical? implementations) breaky on Windows
-------------------------------------------------------------------------------

                 Key: JRUBY-5726
                 URL: http://jira.codehaus.org/browse/JRUBY-5726
             Project: JRuby
          Issue Type: Bug
          Components: Standard Library
    Affects Versions: JRuby 1.6.1
            Reporter: bob mcwhirter
            Assignee: Thomas E Enebo


FileUtils#cp under Windows, Ruby 1.9 mode, can fail with an erroneous "same 
file" error.  It appears, maybe, that if the contents of the src and dest files 
are the same, the cp() feels like we're trying to copy the exact same file.

{noformat}
[INFO] Copying harder
[WARNING] ArgumentError: same file: target/dirA/thefile and 
target/dirB/the_other_file
[WARNING]    fu_each_src_dest at 
file:/C:/Users/bob/.m2/repository/org/jruby/jruby-complete/1.6.1/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1417
[WARNING]   fu_each_src_dest0 at 
file:/C:/Users/bob/.m2/repository/org/jruby/jruby-complete/1.6.1/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1434
[WARNING]    fu_each_src_dest at 
file:/C:/Users/bob/.m2/repository/org/jruby/jruby-complete/1.6.1/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1416
[WARNING]                  cp at 
file:/C:/Users/bob/.m2/repository/org/jruby/jruby-complete/1.6.1/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:391
[WARNING]              (root) at c:/Users/bob/torquebox/fu_cp/fu_cp.rb:12
[WARNING]                load at org/jruby/RubyKernel.java:1073
[WARNING]              (root) at -e:1
{noformat}

A simple script, which run under --1.9 on Windows to demonstrate this issue:

{noformat}
require 'fileutils'
puts 'Setting up'
FileUtils.rm_rf( 'target' )
FileUtils.mkdir_p( 'target/dirA/' )
FileUtils.mkdir_p( 'target/dirB/' )
open( 'target/dirA/thefile', 'w' ) {|f|
  f.puts 'Contents of the file'
}
puts 'Copying'
FileUtils.cp( 'target/dirA/thefile', 'target/dirB/the_other_file' )
puts 'Copying harder'
FileUtils.cp( 'target/dirA/thefile', 'target/dirB/the_other_file' )
{noformat}

For convenience, a handy maven project and git repo is available:

https://github.com/torquebox/fu_cp

Simply clone it, and run `mvn package` to see it work fine on Windows under 1.8 
compatibility.  Then `mvn package -P1.9` to watch it fail under 1.9 with a 
stack.

{noformat}
$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TorqueBox 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ fu_cp 
---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, 
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory 
c:\Users\bob\torquebox\fu_cp\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ fu_cp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ 
fu_cp ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, 
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory 
c:\Users\bob\torquebox\fu_cp\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ 
fu_cp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.5:test (default-test) @ fu_cp ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ fu_cp ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: 
c:\Users\bob\torquebox\fu_cp\target\fu_cp-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- jruby-maven-plugin:0.27.0-SNAPSHOT:jruby (fu, fu#cp) @ fu_cp ---
[INFO] Setting up
[INFO] Copying
[INFO] Copying harder
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.859s
[INFO] Finished at: Tue Apr 19 16:47:12 EDT 2011
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

bob@WIN-FKV9SEEPI2N ~/torquebox/fu_cp (master)
$ mvn package -P1.9
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building TorqueBox 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ fu_cp 
---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, 
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory 
c:\Users\bob\torquebox\fu_cp\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ fu_cp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ 
fu_cp ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, 
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory 
c:\Users\bob\torquebox\fu_cp\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ 
fu_cp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.5:test (default-test) @ fu_cp ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ fu_cp ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: 
c:\Users\bob\torquebox\fu_cp\target\fu_cp-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- jruby-maven-plugin:0.27.0-SNAPSHOT:jruby (fu, fu#cp) @ fu_cp ---
[INFO] Setting up
[INFO] Copying
[INFO] Copying harder
[WARNING] ArgumentError: same file: target/dirA/thefile and 
target/dirB/the_other_file
[WARNING]    fu_each_src_dest at 
file:/C:/Users/bob/.m2/repository/org/jruby/jruby-complete/1.6.1/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1417
[WARNING]   fu_each_src_dest0 at 
file:/C:/Users/bob/.m2/repository/org/jruby/jruby-complete/1.6.1/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1434
[WARNING]    fu_each_src_dest at 
file:/C:/Users/bob/.m2/repository/org/jruby/jruby-complete/1.6.1/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1416
[WARNING]                  cp at 
file:/C:/Users/bob/.m2/repository/org/jruby/jruby-complete/1.6.1/jruby-complete-1.6.1.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:391
[WARNING]              (root) at c:/Users/bob/torquebox/fu_cp/fu_cp.rb:12
[WARNING]                load at org/jruby/RubyKernel.java:1073
[WARNING]              (root) at -e:1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.766s
[INFO] Finished at: Tue Apr 19 16:47:21 EDT 2011
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal 
de.saumya.mojo:jruby-maven-plugin:0.27.0-SNAPSHOT:jruby (fu, fu#cp) on project 
fu_cp: Execution fu, fu#cp of goal 
de.saumya.mojo:jruby-maven-plugin:0.27.0-SNAPSHOT
1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e 
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

bob@WIN-FKV9SEEPI2N ~/torquebox/fu_cp (master)
$
{noformat}








-- 
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