# Wrong load path and/or require

**URL:** <https://www.ruby-forum.com/t/wrong-load-path-and-or-require/140691>\
**Category:** Ruby\
**Created:** [June 17, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/wrong-load-path-and-or-require/140691 "2008-06-17T16:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Remi\_Gillig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@Remi\_Gillig](https://www.ruby-forum.com/u/Remi_Gillig)\
**Post date:** [June 17, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/wrong-load-path-and-or-require/140691/1 "2008-06-17T16:15:43Z")

</div>

Hello,

I am just messing around with Ruby and its internals. I am embedding  
Ruby but without using the library, I directly link the .c files of  
Ruby with my program. I got it working with the same code as I used  
for my program which uses the static library.

The only problem I have is concerning the load path (I am just using  
ruby\_incpush here) :

- with static lib : [".", “lib”]
- without lib : [".\000", “lib\000”]

The consequence of that is that require does not find any file  
anymore. Although, I am not sure if require works correctly either  
because when ruby\_init\_loadpath, the load path contains “.” but does  
not load files.

I would like some advice if anyone already had this kind of problem  
either with or without linking with the library. Thanks.

Remi Gillig.

---

<div class="post-metadata">

**Author:** ![Remi\_Gillig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@Remi\_Gillig](https://www.ruby-forum.com/u/Remi_Gillig)\
**Post date:** [June 22, 2008, 2:05pm UTC](https://www.ruby-forum.com/t/wrong-load-path-and-or-require/140691/2 "2008-06-22T14:05:35Z")

</div>

I took further tests :

- it works perfectly under Ubuntu 8.04 and GCC 4.1
- fails (with a big crash) with GCC 4.1 (MinGW)

I really have no clue why this does not work. I tried to play with the  
stack reserve (in [VS.net](http://VS.net)) but it didn’t work. I thought maybe it’s  
because I mix C/C++ in the binary (yes, I’m really desperate to have  
this work).

So a little summary of the problem :  
I want to embed Ruby but instead of using the library (.lib or .a and/  
or .so or .dll) I link the .c of Ruby directly. This does work (it  
created a proper binary) but has problems with the load path and/or  
require.

Any message will be taken into account. Thanks.

Remi Gillig.

---

<div class="post-metadata">

**Author:** ![Remi\_Gillig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@Remi\_Gillig](https://www.ruby-forum.com/u/Remi_Gillig)\
**Post date:** [June 23, 2008, 11:45pm UTC](https://www.ruby-forum.com/t/wrong-load-path-and-or-require/140691/3 "2008-06-23T23:45:49Z")

</div>

OK, nobody helped in any way, but I found out why it did that.

The win32 function CharNext has 2 versions ANSI or Unicode and  
when you create a project in [VS.net](http://VS.net) it’s Unicode by default.  
If Unicode is chosen, the function becomes CharNextW which  
passes over the null characters because it may detect them as  
valid unicode characters.

This function is in ruby.c in push\_include used by ruby\_incpush.

A cross-platform solution is to replace the line 196, in ruby.c :  
for (s = p; \*s && \*s != sep; s = CharNext(s));  
by  
for (s = p; \*s && _s != sep; ++s);  
because s is "const char_" anyway so there is no need for CharNext.

How do I file a bug for Ruby?

Remi Gillig.

PS : I’m using Ruby 1.8.7-p22
