Forum: JRuby How to properly setup requires

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D M (Guest)
on 2012-06-28 02:04
(Received via mailing list)
I am working on a little gem in Netbeans to relearn Ruby and JRuby and
am having path issues between Netbeans and running it in the CL.

$LOAD_PATH in netbeans gives


in CL it is




Using require_relative works for both, but I don't recall ever having to
use that method.

Using require and actually not getting errors back requires this ugly

unless Dir.exists? "#{Dir.pwd}/lib"
   $LOAD_PATH << "#{Dir.pwd}"
   $LOAD_PATH << "#{Dir.pwd}/lib"

I don't remember ever having to set $LOAD_PATH for either Ruby or JRuby.

Is there a better way to require files in the gem?
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2012-06-29 20:43
so what's the exact problem here?
D M (Guest)
on 2012-06-29 23:06
(Received via mailing list)
The exact problem is why do I have to explicitly set $LOAD_PATH to only
recognize the path of the application? I don't recall ever having to do
that in ruby/jruby before and I have never had to do that in any other

Why does JRuby not know what the path is to the currently executing .rb

given main.rb(which lives in lib) and http_proxy/http.rb why cant JRuby
require http.rb with a simple require 'http_proxy/http' in main.rb
without all the ridiculous $LOAD_PATH contortions?
This topic is locked and can not be replied to.