# Embedded ruby leaves $: empty

**URL:** <https://rubytalk.org/t/embedded-ruby-leaves-empty/59947>\
**Category:** ruby-talk\
**Created:** [6 September 2010 23:40 UTC](https://rubytalk.org/t/embedded-ruby-leaves-empty/59947 "2010-09-06T23:40:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip1](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@Phlip1](https://rubytalk.org/u/Phlip1)\
**Post date:** [6 September 2010 23:40 UTC](https://rubytalk.org/t/embedded-ruby-leaves-empty/59947/1 "2010-09-06T23:40:22Z")

</div>

What's the best way, when embedding Ruby via ruby\_init() and such in  
C, to give it all the same RUBYPATH style library paths as a ruby.exe  
shell call would see?

Where "best" generally means portable to other people's computers,  
where they can be assumed to have a working ruby install of the same  
version?

> **···**
>
> --  
> &nbsp;&nbsp;Phlip

---

<div class="post-metadata">

**Author:** ![Phlip1](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@Phlip1](https://rubytalk.org/u/Phlip1)\
**Post date:** [7 September 2010 04:45 UTC](https://rubytalk.org/t/embedded-ruby-leaves-empty/59947/2 "2010-09-07T04:45:09Z")

</div>

Aaaand just a little reading of ruby.c leads us to:

ruby\_init\_loadpath(); initializes the $: variable ($LOAD\_PATH). It  
will be initialized with the content of the RUBYLIB unix-environment  
variable, plus the location of site\_ruby and the current directory.  
This path is searched whenever you invoke either require or load.  
Therefore is ruby\_init\_loadpath very necessary if you plan to load  
some modules.

[http://aeditor.rubyforge.org/ruby\_cplusplus/index.html](http://aeditor.rubyforge.org/ruby_cplusplus/index.html)

> **···**
>
> On Sep 6, 4:36 pm, Phlip \<phlip2...@gmail.com\> wrote:
> 
> > What's the best way, when embedding Ruby via ruby\_init() and such in  
> > C, to give it all the same RUBYPATH style library paths as a ruby.exe  
> > shell call would see?
> > 
> > Where "best" generally means portable to other people's computers,  
> > where they can be assumed to have a working ruby install of the same  
> > version?
