# Find.find() doesn't work with broken symlinks

**URL:** <https://www.ruby-forum.com/t/find-find-doesnt-work-with-broken-symlinks/90234>\
**Category:** Ruby\
**Created:** [March 26, 2007, 11:19pm UTC](https://www.ruby-forum.com/t/find-find-doesnt-work-with-broken-symlinks/90234 "2007-03-26T23:19:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlorimor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@rlorimor](https://www.ruby-forum.com/u/rlorimor)\
**Post date:** [March 26, 2007, 11:19pm UTC](https://www.ruby-forum.com/t/find-find-doesnt-work-with-broken-symlinks/90234/1 "2007-03-26T23:19:10Z")

</div>

Find.find() seems to filter out broken symlinks. I was hoping to use it  
to get a recursive list of files in directory so I could run various  
tests on each file (like whether or not a symlink points to a valid  
file)

What can I use instead of Find.find()? Is there a better way?

def testsymlinks(srcpath)  
Find.find(srcpath) do |path|  
if File.symlink?(path)  
begin  
File.stat(path)  
rescue Exception =\> e  
$stderr.puts “The symlink " + path + " does not point to  
a valid file. Please check that you have all your network volumes  
mounted.”  
exit(-1)  
end  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![rlorimor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@rlorimor](https://www.ruby-forum.com/u/rlorimor)\
**Post date:** [March 26, 2007, 11:39pm UTC](https://www.ruby-forum.com/t/find-find-doesnt-work-with-broken-symlinks/90234/2 "2007-03-26T23:39:11Z")

</div>

Is there a Rails specific list? I tried subscribing to ’  
removed\_email\_address@domain.invalid’ but haven’t been able to get a response.

- chopper

---

<div class="post-metadata">

**Author:** ![rlorimor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@rlorimor](https://www.ruby-forum.com/u/rlorimor)\
**Post date:** [March 26, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/find-find-doesnt-work-with-broken-symlinks/90234/3 "2007-03-26T23:43:11Z")

</div>

Alle lunedì 26 marzo 2007, removed\_email\_address@domain.invalid ha scritto:

> ```
> File.stat(path)
> rescue Exception => e
> $stderr.puts "The symlink " + path + " does not point to a
> 
> ```
> 
> valid file. Please check that you have all your network volumes mounted."  
> exit(-1)  
> end  
> end  
> end  
> end

Are you sure of this? I tried a small setup (made a directory, created a  
file  
and made a symlink to it, then removed the file) and it works. Find.find  
passes the broken symlink to the block and File.stat raises a SystemCall  
error (Errno::ENOENT). I’m running ruby 1.8.6 on gentoo linux.

Stefano

---

<div class="post-metadata">

**Author:** ![rlorimor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@rlorimor](https://www.ruby-forum.com/u/rlorimor)\
**Post date:** [March 27, 2007, 12:04am UTC](https://www.ruby-forum.com/t/find-find-doesnt-work-with-broken-symlinks/90234/4 "2007-03-27T00:04:14Z")

</div>

chopper wrote:

> Is there a Rails specific list? I tried subscribing to ’  
> removed\_email\_address@domain.invalid’ but haven’t been able to get a response.
> 
> - chopper

> **[Ruby on Rails](https://rubyonrails.org)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

–  
Phillip “CynicalRyan” Gawlowski

Eek! That was supposed to be My Special Law, _MY_ special law, I tell  
you!

T/
