Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error during running a ruby file using irb on Netbeans 6.9.1  RSS feed

Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using Netbeans 6.9.1 and imported a "what i think is a rails project" - it has a rake file that does among other things creating gems, specs and stuff from a bunch of .rb files. But you see it is no web application, so perhaps it is just a Ruby project with rake for build. Anyways, my objective is to run a Ruby file called the_ruby.rb - code snippet as follows:

I kind of thought it's cool to run it using IRB in NB (got fed up with using Eclipse Aptana Studio's debugger, which is a different issue altogether). These were what I did to invoke the method get_somedata():

1. Read the input file for the first parameter:

file ="path-to-file.xml", "rb")
contents =

2. Secondly, I figured I need to add up all dependencies to the $LOAD_PATH or $:

Firstly, the following observation


=> ["C:/Users/mcn/myproj/workspaces/ws2/projec/lib-IC:/Users/mcn/myproj/workspaces/ws2/projec/test", "C:/Users/mcn/myproj/workspaces/ws2/projec/spec", "C:/Program Files/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/site_ruby/1.8", "C:/Program Files/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/site_ruby/shared", "C:/Program Files/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/1.8", "."]

Attempt-1: I tried a link:

require ("./lib/the_ruby.rb")

LoadError: no such file to load -- depend1
from ./lib/the_ruby.rb:4:in `require'
from ./lib/the_ruby.rb:4
from ./lib/the_ruby.rb:6:in `require'
from (irb):6

Do I need to do something after the Dir.glob but before the require tp make this work?

Attempt-2: Then I read up more on LOAD_PATH and got to a link:

Again, I was clueless how this is going to add files in my ./lib/*.rb files to the LOAD_PATH. As I suspected doing a $: did not show any of the .rb files.

Anyways, just being optimistic and awaiting magic, I tried to invoke a instance nmethod:

Gave the following error:

NameError: uninitialized constant MyRubyCaller
from (irb):16

I am not sure what I am doing wrong, but I do suspect this has to do to the .rb files not being in LOAD_PATH. How do I run this on IRB. Please advice and help.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!