# Does Ruby has built-in way to traverse symlinks?

**URL:** <https://www.ruby-forum.com/t/does-ruby-has-built-in-way-to-traverse-symlinks/209087>\
**Category:** Ruby\
**Created:** [July 5, 2011, 2:42pm UTC](https://www.ruby-forum.com/t/does-ruby-has-built-in-way-to-traverse-symlinks/209087 "2011-07-05T14:42:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [July 5, 2011, 2:42pm UTC](https://www.ruby-forum.com/t/does-ruby-has-built-in-way-to-traverse-symlinks/209087/1 "2011-07-05T14:42:55Z")

</div>

I have a code that uses Dir[data\_dir + ‘/\*\*/\*’] to get all the files.

But this doesn’t work when some directories as symbolic links.

I’ve googled around but couldn’t find a built-in way to do this. So it  
seems I’ll have to write my own code.

Isn’t this functionaity desired by other programmers? Am I the only soul  
in the world who needs this? Souldn’t this be filed as a feature request  
for Ruby?

If anybody has some short code to do this, I’d be happy to see it (I can  
do this myself, but people here sometimes amaze me with clever/compact  
thinking).

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [July 6, 2011, 11:18pm UTC](https://www.ruby-forum.com/t/does-ruby-has-built-in-way-to-traverse-symlinks/209087/2 "2011-07-06T23:18:44Z")

</div>

File.readlink()

Works?

But yes, file a feature request. If the use case is logic and can be  
explain.

I myself dislike the distinction of  
File and  
FileUtils

behaving differently. 😕

One has .cp\_r  
the other one does not …
