# When $0 isn't what I want

**URL:** <https://www.ruby-forum.com/t/when-0-isnt-what-i-want/115134>\
**Category:** Ruby\
**Created:** [September 20, 2007, 10:53pm UTC](https://www.ruby-forum.com/t/when-0-isnt-what-i-want/115134 "2007-09-20T22:53:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpeterson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58f4c7/32.png) [@cpeterson](https://www.ruby-forum.com/u/cpeterson)\
**Post date:** [September 20, 2007, 10:53pm UTC](https://www.ruby-forum.com/t/when-0-isnt-what-i-want/115134/1 "2007-09-20T22:53:50Z")

</div>

When using eruby for web development, $0 for any given .rhtml file is  
always ‘eruby’. This also means that any time I want to use a path  
relative to the location of the .rhtml file being accessed, I’m out of  
luck: paths are relative to the eruby executable instead.

How would I go about using relative paths from a current working path of  
the .rhtml file, rather than from the eruby executable? I’d prefer a  
more “portable” design for the code in the pages I’m putting together,  
rather than having to use absolute paths that may lose their accuracy if  
the web pages in question ever need to be moved to another server.

---

<div class="post-metadata">

**Author:** ![cpeterson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58f4c7/32.png) [@cpeterson](https://www.ruby-forum.com/u/cpeterson)\
**Post date:** [September 20, 2007, 11:06pm UTC](https://www.ruby-forum.com/t/when-0-isnt-what-i-want/115134/2 "2007-09-20T23:06:52Z")

</div>

> When using eruby for web development, $0 for any given .rhtml file

File.dirname( **FILE** )

Variations with Pathname are much more programmer-friendly, too!

---

<div class="post-metadata">

**Author:** ![cpeterson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58f4c7/32.png) [@cpeterson](https://www.ruby-forum.com/u/cpeterson)\
**Post date:** [September 20, 2007, 11:24pm UTC](https://www.ruby-forum.com/t/when-0-isnt-what-i-want/115134/3 "2007-09-20T23:24:55Z")

</div>

On Fri, Sep 21, 2007 at 06:06:04AM +0900, Phlip wrote:

> > When using eruby for web development, $0 for any given .rhtml file
> 
> File.dirname( **FILE** )

I coulda sworn I’d tried that already. Apparently not.

Thanks!
