# How to tell Ruby the relative path of file

**URL:** <https://www.ruby-forum.com/t/how-to-tell-ruby-the-relative-path-of-file/125399>\
**Category:** Ruby\
**Created:** [January 8, 2008, 9:00pm UTC](https://www.ruby-forum.com/t/how-to-tell-ruby-the-relative-path-of-file/125399 "2008-01-08T21:00:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [January 8, 2008, 9:00pm UTC](https://www.ruby-forum.com/t/how-to-tell-ruby-the-relative-path-of-file/125399/1 "2008-01-08T21:00:44Z")

</div>

Hi all,

I use window vista version. I want to open a file using relative path.I  
wonder it is possible and how.

Thank you very much,

Li

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [September 3, 2009, 7:10pm UTC](https://www.ruby-forum.com/t/how-to-tell-ruby-the-relative-path-of-file/125399/2 "2009-09-03T19:10:21Z")

</div>

> I use window vista version. I want to open a file using relative path.I  
> wonder it is possible and how.

Check out the “require\_all” gem which has a require\_rel method.

or “require\_relative” from backports/1.9:

> **[GitHub - marcandre/backports: The latest features of Ruby backported to older...](https://github.com/marcandre/backports/tree/master)**
>
> master

Also note that if you want to calculate a relative path between two  
files, use Pathname#relative\_path\_from

GL.  
-r
