JRuby

FileUtils.chown_R produces ArgumentError when the directory contains a symlink

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.2
  • Fix Version/s: JRuby 1.4
  • Component/s: Core Classes/Modules
  • Description:
    Hide

    Given a directory structure like this:

    LUNCHBOX ~/test> ls -alh
    total 4.0K
    drwxr-xr-x 6 coda staff 204 2009-06-15 22:33 .
    drwx------+ 87 coda staff 2.9K 2009-06-15 22:32 ..
    lrwxr-xr-x 1 coda staff 3 2009-06-15 22:33 four -> two
    drwxr-xr-x 2 coda staff 68 2009-06-15 22:32 one
    drwxr-xr-x 2 coda staff 68 2009-06-15 22:32 three
    drwxr-xr-x 2 coda staff 68 2009-06-15 22:32 two

    This code:

    FileUtils.chown_R("coda", nil, "/Users/coda/test", :verbose => false)

    raises an ArgmentException:

    /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1374:in `check_have_lchown?': wrong # of arguments(2 for 3) (ArgumentError)
    from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1367:in `have_lchown?'
    from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1222:in `chown'
    from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:961:in `chown_R'
    from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1324:in `preorder_traverse'
    from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:959:in `chown_R'
    from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:958:in `each'
    from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:958:in `chown_R'

    The same code in Ruby does not. The exception is only raised when there are symbolic links in the path to be chown'd.

    Show
    Given a directory structure like this: LUNCHBOX ~/test> ls -alh total 4.0K drwxr-xr-x 6 coda staff 204 2009-06-15 22:33 . drwx------+ 87 coda staff 2.9K 2009-06-15 22:32 .. lrwxr-xr-x 1 coda staff 3 2009-06-15 22:33 four -> two drwxr-xr-x 2 coda staff 68 2009-06-15 22:32 one drwxr-xr-x 2 coda staff 68 2009-06-15 22:32 three drwxr-xr-x 2 coda staff 68 2009-06-15 22:32 two This code: FileUtils.chown_R("coda", nil, "/Users/coda/test", :verbose => false) raises an ArgmentException: /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1374:in `check_have_lchown?': wrong # of arguments(2 for 3) (ArgumentError) from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1367:in `have_lchown?' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1222:in `chown' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:961:in `chown_R' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1324:in `preorder_traverse' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:959:in `chown_R' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:958:in `each' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:958:in `chown_R' The same code in Ruby does not. The exception is only raised when there are symbolic links in the path to be chown'd.
  • Environment:
    Hide
    Darwin lunchbox.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
    java version "1.6.0_13"
    Java(TM) SE Runtime Environment (build 1.6.0_13-b03-206)
    Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-82, mixed mode)
    jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-06-10 rev 6586) [x86_64-java]
    Show
    Darwin lunchbox.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 java version "1.6.0_13" Java(TM) SE Runtime Environment (build 1.6.0_13-b03-206) Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-82, mixed mode) jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-06-10 rev 6586) [x86_64-java]
  1. lchown-testcase.rb
    (0.4 kB)
    Coda Hale
    23/Jun/09 2:42 PM
  2. lchown-testcase.rb
    (0.4 kB)
    Coda Hale
    16/Jun/09 12:41 AM

Activity

Hide
Coda Hale added a comment - 16/Jun/09 12:41 AM

Here's a test case for the bug.

My output looks like this:

UNCHBOX ~> ruby ~/Desktop/lchown-testcase.rb /tmp/lchown-test
LUNCHBOX ~> jruby ~/Desktop/lchown-testcase.rb /tmp/lchown-test
/opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1374:in `check_have_lchown?': wrong # of arguments(2 for 3) (ArgumentError)
from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1367:in `have_lchown?'
from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1222:in `chown'
from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:961:in `chown_R'
from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1324:in `preorder_traverse'
from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:959:in `chown_R'
from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:958:in `each'
from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:958:in `chown_R'
from /Users/coda/Desktop/lchown-testcase.rb:8

Show
Coda Hale added a comment - 16/Jun/09 12:41 AM Here's a test case for the bug. My output looks like this: UNCHBOX ~> ruby ~/Desktop/lchown-testcase.rb /tmp/lchown-test LUNCHBOX ~> jruby ~/Desktop/lchown-testcase.rb /tmp/lchown-test /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1374:in `check_have_lchown?': wrong # of arguments(2 for 3) (ArgumentError) from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1367:in `have_lchown?' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1222:in `chown' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:961:in `chown_R' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:1324:in `preorder_traverse' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:959:in `chown_R' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:958:in `each' from /opt/local/share/java/jruby/lib/ruby/1.8/fileutils.rb:958:in `chown_R' from /Users/coda/Desktop/lchown-testcase.rb:8
Hide
Charles Oliver Nutter added a comment - 16/Jun/09 3:02 AM

This is reportedly the only bug preventing Rip from working, so it would be nice to get it fixed.

Show
Charles Oliver Nutter added a comment - 16/Jun/09 3:02 AM This is reportedly the only bug preventing Rip from working, so it would be nice to get it fixed.
Hide
Coda Hale added a comment - 23/Jun/09 2:41 PM

Just confirmed – this bug affects JRuby 1.3.1. (MacPorts didn't have a current port at the time I reported this.)

Show
Coda Hale added a comment - 23/Jun/09 2:41 PM Just confirmed – this bug affects JRuby 1.3.1. (MacPorts didn't have a current port at the time I reported this.)
Hide
Coda Hale added a comment - 23/Jun/09 2:42 PM

An improved testcase, minus typos and brainfarts.

Show
Coda Hale added a comment - 23/Jun/09 2:42 PM An improved testcase, minus typos and brainfarts.
Hide
Nick Sieger added a comment - 18/Aug/09 1:37 PM

Should be fixed in d1ae677.

Show
Nick Sieger added a comment - 18/Aug/09 1:37 PM Should be fixed in d1ae677.

People

  • Assignee:
    Unassigned
    Reporter:
    Coda Hale
  • Votes:
    1
    Watchers:
    0

Dates

  • Created:
    16/Jun/09 12:36 AM
    Updated:
    18/Aug/09 1:37 PM
    Resolved:
    18/Aug/09 1:37 PM