# Ruby 1.9 - equivalent of ruby\_run()?

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-equivalent-of-ruby-run/130751>\
**Category:** Ruby\
**Created:** [March 3, 2008, 1:31am UTC](https://www.ruby-forum.com/t/ruby-1-9-equivalent-of-ruby-run/130751 "2008-03-03T01:31:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@snk](https://www.ruby-forum.com/u/snk)\
**Post date:** [March 3, 2008, 1:31am UTC](https://www.ruby-forum.com/t/ruby-1-9-equivalent-of-ruby-run/130751/1 "2008-03-03T01:31:41Z")

</div>

Hello,

In Ruby 1.8, I was able to start the Ruby interpreter using ruby\_run():

char\* file = “foobar.rb”;  
ruby\_script(file);  
rb\_load\_file(file);  
ruby\_run(); // start the interpreter

In Ruby 1.9, there is a ruby\_run\_node() function instead, but I have not  
been able to use it successfully. I tried:

char\* file = “foobar.rb”;  
ruby\_script(file);  
rb\_load\_file(file);  
ruby\_run\_node(NULL); // start the interpreter

And I also tried:

char\* file = “foobar.rb”;  
ruby\_script(file);  
rb\_load\_file(file);  
ruby\_run\_node(ruby\_options(0, NULL)); // start the interpreter

And I also tried:

char\* argv[] = {“foobar.rb”};  
ruby\_run\_node(ruby\_options(1, argv)); // start the interpreter

None of these worked; the interpreter would immediately dump core.

What is the correct way to do this?

Thanks for your consideration.

---

<div class="post-metadata">

**Author:** ![snk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@snk](https://www.ruby-forum.com/u/snk)\
**Post date:** [March 3, 2008, 6:26am UTC](https://www.ruby-forum.com/t/ruby-1-9-equivalent-of-ruby-run/130751/2 "2008-03-03T06:26:49Z")

</div>

Suraj K. wrote:

> In Ruby 1.9, there is a ruby\_run\_node() function instead, but I have not  
> been able to use it successfully. I tried:
> 
> char\* file = “foobar.rb”;  
> ruby\_script(file);  
> rb\_load\_file(file);  
> ruby\_run\_node(NULL); // start the interpreter

I hunted around in the Ruby 1.9.0 source code and found an example in  
load.c. The solution is to pass the return value of rb\_load\_file() to  
ruby\_run\_node():

char\* file = “foobar.rb”;  
ruby\_script(file);  
void\* node = rb\_load\_file(file);  
ruby\_run\_node(node); // start the interpreter
