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?
on 2012-06-28 02:04
on 2012-06-29 23:06
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?
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.