Skip to content

[bug] find() breaks if a broken link is passed as argument #18

@mauroseb

Description

@mauroseb

Description
find() breaks if a broken link is passed as argument.

Version

ruby 3.3.5 (2024-09-03 revision ef084cc8f4)

Environment
Ruby container running on Apple Mac Book Pro M2

Reproducer

Create a broken link and pass it to find().

$ podman run --rm -d --name ruby-3.3-test docker.io/ruby:latest sleep infinity   
8f3c2156fd77aca74ca45f5f1893c94522afc822d271c58c015eae0d4973b7f2

$ podman exec -it ruby-3.3-test bash
root@8f3c2156fd77:/# ln -s broken broken-link
root@8f3c2156fd77:/# irb
irb(main):036> require 'find'
irb(main):041* Find.find('broken-link')  do |path|
irb(main):042*   puts path
irb(main):043> end
/usr/local/lib/ruby/3.3.0/find.rb:45:in `block in find': No such file or directory - broken-link (Errno::ENOENT)
        from /usr/local/lib/ruby/3.3.0/find.rb:45:in `collect!'
        from /usr/local/lib/ruby/3.3.0/find.rb:45:in `find'
        from (irb):41:in `<main>'
        from <internal:kernel>:187:in `loop'
        from /usr/local/lib/ruby/gems/3.3.0/gems/irb-1.13.1/exe/irb:9:in `<top (required)>'
        from /usr/local/bin/irb:25:in `load'
        from /usr/local/bin/irb:25:in `<main>'

Expected Behavior
The function should handle the exception cleanly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions