[jruby] require vs. require_relative, used from within a scriptlet

changepoint_advi.fischer at extaccount.com changepoint_advi.fischer at extaccount.com
Tue Jan 12 01:42:11 JST 2016


I'm using this one:

jruby 1.7.23 (1.9.3p551) 2015-11-24 f496dd5 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_79-b15 +jit [Windows 7-amd64]

I will try to put together an isolated example and post it....

Mit freundlichen Grüßen / Best Regards
Team Flashprozesstools
Ronald Fischer

Meitnerstr. 8
5. Stock / 85
70563 Stuttgart

Im Auftrag der/on behalf of
Daimler AG

mailto: changepoint_advi.fischer at extaccount.com

Wenn diese E-Mail nicht für Sie bestimmt ist, bitten wir Sie, uns
umgehend über den irrtümlichen Empfang zu informieren und
diese E-Mail zu löschen. Wir danken Ihnen für Ihre Unterstützung.

From: JRuby [mailto:jruby-bounces at ruby-lang.org] On Behalf Of christian
Sent: Monday, January 11, 2016 5:36 PM
To: JRuby project mailing list
Subject: Re: [jruby] require vs. require_relative, used from within a scriptlet

this should actually work. which jruby version are you using ?

On Mon, Jan 11, 2016 at 3:11 PM, <changepoint_advi.fischer at extaccount.com<mailto:changepoint_advi.fischer at extaccount.com>> wrote:
I'm running my JRuby application via a ScriptingContainer. Everything is in a Jar File, and the Ruby source files are all within the same subdirectory in the jar. Seen from the jar file as the base directory, by ruby files would be rdir/scriptlet.rb and rdir/application.rb. The scriptlet is called by

    container.runScriptlet(org.jruby.embed.PathType.CLASSPATH,"rdir/scriptlet.rb");

Within scriptlet.rb, I would like to require application.rb. I can do this in the following way:

    require 'rdir/application' # This works

I can NOT do this in the following way:

    require_relative 'application" # This does not work

I had expected, that both would work. require_relative looks up the included file relative to the directory of the including file, which is in both cases 'rdir'. Why can't I use require_relative here? Does 'require_relative' only work in this way, if it is called from within a file which itself is being processed by a 'require'/'require_relative' command?

I would prefer not having 'rdir' hardcoded in my file, and therefore would like to use require_relative, if possible.

Ronald

If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.


If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ruby-lang.org/pipermail/jruby/attachments/20160111/8089d217/attachment-0001.html>


More information about the JRuby mailing list