File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ruby and the fly likes Error during running a ruby file using irb on Netbeans 6.9.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » Ruby
Bookmark "Error during running a ruby file using irb on Netbeans 6.9.1" Watch "Error during running a ruby file using irb on Netbeans 6.9.1" New topic
Author

Error during running a ruby file using irb on Netbeans 6.9.1

Mahesh Chandran
Greenhorn

Joined: Mar 23, 2011
Posts: 20
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 = File.open("path-to-file.xml", "rb")
contents = file.read
file.close

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: http://rubynotebook.blogspot.in/2013/01/load-or-require-files-into-irb.html

Dir.glob("C:/Users/mcn/myproj/workspaces/ws2/projec/lib/*.rb")
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: http://stackoverflow.com/questions/2587128/what-is-the-quickest-way-to-recursively-add-directories-onto-the-load-path-in-r

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.

Regards
Mahesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error during running a ruby file using irb on Netbeans 6.9.1
 
Similar Threads
ruby script/server is not working
Ruby Question: Problems with IRB & simple Draw app
Ruby on Rails question: yaml problem with scaffold generation
Error while calling ruby code using JRuby in Eclipse Aptana Studio 3 Terminal View
Ruby 1.8 and MySql problem