-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[jrubyscripting] Apply RUBYLIB configuration to $LOAD_PATH #12123
Conversation
5794a66
to
f28ff6f
Compare
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
...main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineConfiguration.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
@lolodomo I've changed it to |
Code guideline: https://www.openhab.org/docs/developer/guidelines.html#f-logging
So error should rarely be used. If you see other inappropriate usages of error, yes please fix them too. |
@lolodomo I've given this further thought, but I still can't determine with 100% certainty whether Essentially the code tries to add to the $LOAD_PATH global variable, and catches the exception in case of error. In such situation, the intended effect would not have been achieved, so user scripts that want to load additional libraries from the LOAD_PATH would fail. Wouldn't this be considered that something is "tremendously wrong and cannot function normally"? Furthermore, actions are required from the user to remedy the situation (by fixing the config that caused the error). |
As I understand, you are adding a new feature, not a mandatory feature, the system can work well without it. Not a critical error.
|
This isn't actually a new feature, more a bug fix. Originally the addon allows to set
However this isn't currently working. So this PR adds RUBYLIB into LOAD_PATH post scriptEngine instantiation to make it work. The same solution is currently implemented within the jruby helper library, but since this helper library isn't a part of the addon, the best solution is to incorporate this patch into the addon. |
The RUBYLIB setting will not work for those who aren't using the helper library (eg in a GUI rule). A decision was made to implement the fix in the helper library first because it was the easiest to do at the time. This PR now includes the fix in the addon, so it would work with or without the helper library, e.g. in a GUI rule. See the discussion here boc-tothefuture/openhab-jruby#267 (comment) and here boc-tothefuture/openhab-jruby#267 (comment) |
@lolodomo if you believe the proper level is indeed warn, then this PR can be merged now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…2123) * [jrubyscripting] Apply RUBYLIB configuration to $LOAD_PATH Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
…2123) * [jrubyscripting] Apply RUBYLIB configuration to $LOAD_PATH Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au> Signed-off-by: Nick Waterton <n.waterton@outlook.com>
…2123) * [jrubyscripting] Apply RUBYLIB configuration to $LOAD_PATH Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
…2123) * [jrubyscripting] Apply RUBYLIB configuration to $LOAD_PATH Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
…2123) * [jrubyscripting] Apply RUBYLIB configuration to $LOAD_PATH Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au> Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
The
rubylib
addon configuration is supposed to alter the $LOAD_PATH but currently it doesn't. As a result, personal libraries located in RUBYLIB path won't be found. Currently a workaround is applied in the helper library to parse RUBYLIB and add the paths into $LOAD_PATH.However, GUI users who opt not to use the helper library will not be able to load personal libraries based on the
rubylib
search path.This PR remedies this situation by updating
$LOAD_PATH
within the addon.