# Help with require, symlinks

**URL:** <https://www.ruby-forum.com/t/help-with-require-symlinks/62438>\
**Category:** Ruby\
**Created:** [June 4, 2006, 8:36pm UTC](https://www.ruby-forum.com/t/help-with-require-symlinks/62438 "2006-06-04T20:36:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![curi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e68b1a/32.png) [@curi](https://www.ruby-forum.com/u/curi)\
**Post date:** [June 4, 2006, 8:36pm UTC](https://www.ruby-forum.com/t/help-with-require-symlinks/62438/1 "2006-06-04T20:36:19Z")

</div>

I’m on OS X 10.4.6

i want to be able to require my files without the full path. i want  
to keep them in my home directory so i don’t lose them. i tried:

sudo ln -s /Users/curi/me/rubylib /usr/local/lib/ruby/site\_ruby/  
myrubylib

it made the link. observe:

curi-g5:/usr/local/lib/ruby/site\_ruby curi$ cd myrubylib  
curi-g5:/usr/local/lib/ruby/site\_ruby/myrubylib curi$ ls  
curi.rb

however:

require “curi” # can’t find the file

require “/Users/curi/me/rubylib/curi” # this works  
require “/usr/local/lib/ruby/site\_ruby/myrubylib/curi” # this works too

not sure what i’m doing wrong or how to do this properly…

BTW:

curi-g5:/usr/local/lib/ruby/site\_ruby curi$ ruby -e “puts $:”  
/usr/local/lib/ruby/site\_ruby/1.8  
/usr/local/lib/ruby/site\_ruby/1.8/powerpc-darwin8.5.0  
/usr/local/lib/ruby/site\_ruby  
/usr/local/lib/ruby/1.8  
/usr/local/lib/ruby/1.8/powerpc-darwin8.5.0  
.

– Elliot T.

> **[Curiosity Blog – Elliot Temple](https://www.curi.us/blog/)**
>
> A philosophy blog

---

<div class="post-metadata">

**Author:** ![curi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e68b1a/32.png) [@curi](https://www.ruby-forum.com/u/curi)\
**Post date:** [June 4, 2006, 8:42pm UTC](https://www.ruby-forum.com/t/help-with-require-symlinks/62438/2 "2006-06-04T20:42:34Z")

</div>

Elliot T. wrote:

> curi-g5:/usr/local/lib/ruby/site\_ruby/myrubylib curi$ ls
> 
> – Elliot T.  
> [Curiosity Blog – Elliot Temple](http://www.curi.us/blog/)

Might it be simpler for you to just add your home directory to Ruby’s  
search path by using the RUBYLIB environment variable?

export RUBYLIB=/Users/curi/me/rubylib

---

<div class="post-metadata">

**Author:** ![curi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e68b1a/32.png) [@curi](https://www.ruby-forum.com/u/curi)\
**Post date:** [June 4, 2006, 8:48pm UTC](https://www.ruby-forum.com/t/help-with-require-symlinks/62438/3 "2006-06-04T20:48:53Z")

</div>

On Jun 4, 2006, at 8:35 PM, Elliot T. wrote:

> I’m on OS X 10.4.6
> 
> i want to be able to require my files without the full path. i want  
> to keep them in my home directory so i don’t lose them.

Try this:

# .profile/.bash\_profile/.whatever

export RUBYLIB="$HOME/to/your/files

Straight out of Ruby’s man page.

$ man ruby

– Daniel

---

<div class="post-metadata">

**Author:** ![curi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e68b1a/32.png) [@curi](https://www.ruby-forum.com/u/curi)\
**Post date:** [June 4, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/help-with-require-symlinks/62438/4 "2006-06-04T21:47:20Z")

</div>

On Jun 4, 2006, at 20:35, Elliot T. wrote:

> I’m on OS X 10.4.6
> 
> i want to be able to require my files without the full path. i want  
> to keep them in my home directory so i don’t lose them. i tried:
> 
> sudo ln -s /Users/curi/me/rubylib /usr/local/lib/ruby/site\_ruby/  
> myrubylib

> require “curi” # can’t find the file

Others have already mentioned RUBYLIB, but let me note that the very  
myrubylib under site\_ruby is _not_ in $:. Thus, you’d need to specify  
the parent directoy as well:

require ‘myrubylib/curi’

You load the core library smtp.rb as ‘net/smtp’ because of the same  
reason, smtp.rb lives in

/usr/local/lib/ruby/1.8/net/smtp.rb

and the directory in the load path there is /usr/local/lib/ruby/1.8.

RUBYLIB is the canonical solution to that, but at least you know why  
your test is not working.

– fxn
