Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8722283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:22:39+00:00 2026-06-13T07:22:39+00:00

BACKGROUND: I am using JRuby in an eclipse plugin for my product. I have

  • 0

BACKGROUND:

I am using JRuby in an eclipse plugin for my product. I have a bunch of scripts that define a DSL and perform operations for me. I want to be able to dynamically reload these scripts whenever required. The scripts could change themselves on file system and moreover the location of the scripts could also change. I could even have multiple copies on file system of slightly modified/changed scripts. Each time I want scripts from a specific location to be utilized.

As I have understood so far, using “load” instead of “require” should do the job. So now if before calling any Ruby methods/functions I use “load ‘XXX.rb'”, it will reload the XXX.rb utilizing the new changes.

PROBLEM:

In my code I am using ScriptingContainer to run scriplets to access ruby functions. I set load paths on this scripting container to indicate from which locations the scripts should be loaded. However, the problem is that on subsequent calls and even with different instances of ScriptingContainer, I have noticed that the scripts that were loaded the first time are utilized every time. “load” reloads them, but after loading those scripts once, the next time I might need to load similar scripts from a different location but its not happening.

My assumption was that utilizing a different scripting container instance should have done the job but it seems that the load paths are globally set somewhere and calling “setLoadPath” on new ScriptingContainer instances either does not modify existing paths or only appends. If the latter case is true then probably when searching for scripts they are always found on oldest paths set and newer load paths get ignored.

Any ideas???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:22:40+00:00Added an answer on June 13, 2026 at 7:22 am

    The solution is to specify scope for a ScriptingContainer instance when creating it. One of the ScriptingContainer constructors takes in a parameter of type LocalContextScope, use one of the constants to define the scope. See LocalContextScope.java

    To test this defect and solution I have written a small snippet. You may try it out:

    public class LoadPathProblem {
    
      public static void main(String[] args) {
        // Create the first container
        ScriptingContainer c1 = new ScriptingContainer();
        // FIX ScriptingContainer c1 = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
    
        // Setting a load path for scripts
        String path1[] = new String[] { ".\\scripts\\one" };
        c1.getProvider().setLoadPaths(Arrays.asList(path1));
    
        // Run a script that requires loading scripts in the load path above
        EvalUnit unit1 = c1.parse("load 'test.rb'\n" + "testCall");
        IRubyObject ret1 = unit1.run();
        System.out.println(JavaEmbedUtils.rubyToJava(ret1));
    
        // Create the second container, completely independent of the first one
        ScriptingContainer c2 = new ScriptingContainer();
        // FIX ScriptingContainer c2 = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
    
        // Setting a different load path for this container as compared to the first container
        String path2[] = new String[] { ".\\Scripts\\two" };
        c2.getProvider().setLoadPaths(Arrays.asList(path2));
    
        // Run a script that requires loading scripts in the different path
        EvalUnit unit2 = c2.parse("load 'test.rb'\n" + "testCall");
        IRubyObject ret2 = unit2.run();
    
        /*
         * PROBLEM: Expected here that the function testCall will be called from
         * the .\scripts\two\test.rb, but as you can see the output says that
         * the function was still called from .\scripts\one\test.rb.
         */
        System.out.println(JavaEmbedUtils.rubyToJava(ret2));
      }
    }
    

    Test scripts to try out the above code can be in different folders but with the same filename (“test.rb” for the above example:

    ./scripts/one/test.rb

    def testCall
      "Called one"
    end
    

    ./scripts/two/test.rb

    def testCall
      "Called two"
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to make android icons with transparent background using eclipse.I know that we can
Background: I want to deploy a small JRuby-On-Rails-Application using warblers executable war, so I
i have 3 navigation controller and i want to change each background using different
I have given a table background image using css background-image property. The cells are
Background: I have a Java application that many programming clients interface with. Recently, a
I am from DW/BI background using SAS for many years now I have task
BACKGROUND Using Xdebug with PHP and Komodo IDE, and Eclipse PDT. Xdebug is installed
I have a project which downloads images in background using NSOperationQueue . It was
I have created plugin for background service (to run the application in background) in
This is some background to my problem... I have been using 3rd Party as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.