# Embedded ruby leaves $: empty

**URL:** <https://www.ruby-forum.com/t/embedded-ruby-leaves-empty/194554>\
**Category:** Ruby\
**Created:** [September 7, 2010, 2:24am UTC](https://www.ruby-forum.com/t/embedded-ruby-leaves-empty/194554 "2010-09-07T02:24:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [September 7, 2010, 2:24am UTC](https://www.ruby-forum.com/t/embedded-ruby-leaves-empty/194554/1 "2010-09-07T02:24:48Z")

</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?

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [September 7, 2010, 6:45am UTC](https://www.ruby-forum.com/t/embedded-ruby-leaves-empty/194554/2 "2010-09-07T06:45:51Z")

</div>

On Sep 6, 4:36 pm, Phlip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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?

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)
