How to properly setup requires

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

/home/david/projects/http-proxy/lib-I/home/david/projects/http-proxy/spec
/home/david/apps/jruby/lib/ruby/site_ruby/1.9
/home/david/apps/jruby/lib/ruby/shared
/home/david/apps/jruby/lib/ruby/1.9

in CL it is

/home/david/apps/jruby/lib/ruby/site_ruby/1.9

/home/david/apps/jruby/lib/ruby/shared

/home/david/apps/jruby/lib/ruby/1.9

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
hack

unless Dir.exists? “#{Dir.pwd}/lib”
$LOAD_PATH << “#{Dir.pwd}”
else
$LOAD_PATH << “#{Dir.pwd}/lib”
end

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?

so what’s the exact problem here?

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
language.

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

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?