JRuby

FileUtils.chown_R produces ArgumentError when the directory contains a symlink

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.2
  • Fix Version/s: JRuby 1.4
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
  • Number of attachments :
    2

Description

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.

  1. lchown-testcase.rb
    23/Jun/09 2:42 PM
    0.4 kB
    Coda Hale
  2. lchown-testcase.rb
    16/Jun/09 12:41 AM
    0.4 kB
    Coda Hale

Activity

Hide
Coda Hale added a comment -

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

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

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

An improved testcase, minus typos and brainfarts.

Show
Coda Hale added a comment - An improved testcase, minus typos and brainfarts.
Hide
Nick Sieger added a comment -

Should be fixed in d1ae677.

Show
Nick Sieger added a comment - Should be fixed in d1ae677.

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: