Note, this is what happens if you have the wrong credentials for the /etc/openhab/automation folder.
Just updated to 3.2.0 Release Build. (Ubuntu)
All is well.
After reading the Release notes in Kai’s 3.2.0 is here post, I decided to try out JSScript’ing.
Prior to this, I have used DSL only.
When installing JSScript, I noticed these two entries in the log:
2021-12-29 22:55:48.509 [WARN ] [nternal.fs.watch.JSDependencyTracker] - Failed to create watched directory: /etc/openhab/automation/js/node_modules
2021-12-29 22:55:48.535 [WARN ] [rulesupport.loader.ScriptFileWatcher] - Failed to create watched directory: /etc/openhab/automation/js
Letting it slide, I tried creating my first ever JS rule (a 1s test-ticker), only to get this in the log:
2021-12-29 23:35:01.972 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error while creating ScriptEngine
org.graalvm.polyglot.PolyglotException: Error: Invalid CommonJS root folder: /etc/openhab/automation/js/node_modules
at org.graalvm.polyglot.Context.eval(Context.java:379) ~[?:?]
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.evalInternal(GraalJSScriptEngine.java:376) ~[?:?]
at com.oracle.truffle.js.scriptengine.GraalJSBindings.initGlobal(GraalJSBindings.java:94) ~[?:?]
at com.oracle.truffle.js.scriptengine.GraalJSBindings.initContext(GraalJSBindings.java:90) ~[?:?]
at com.oracle.truffle.js.scriptengine.GraalJSBindings.requireContext(GraalJSBindings.java:84) ~[?:?]
at com.oracle.truffle.js.scriptengine.GraalJSBindings.put(GraalJSBindings.java:127) ~[?:?]
at javax.script.SimpleScriptContext.setAttribute(SimpleScriptContext.java:246) ~[java.scripting:?]
at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.addAttributeToScriptContext(ScriptEngineManagerImpl.java:254) ~[bundleFile:?]
at org.openhab.core.automation.module.script.internal.ScriptEngineManagerImpl.createScriptEngine(ScriptEngineManagerImpl.java:144) [bundleFile:?]
at org.openhab.core.automation.module.script.internal.handler.AbstractScriptModuleHandler.createScriptEngine(AbstractScriptModuleHandler.java:92) [bundleFile:?]
at org.openhab.core.automation.module.script.internal.handler.AbstractScriptModuleHandler.getScriptEngine(AbstractScriptModuleHandler.java:88) [bundleFile:?]
at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:59) [bundleFile:?]
at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1180) [bundleFile:?]
at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:988) [bundleFile:?]
at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:89) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
2021-12-29 23:35:01.984 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule '915601a534': Fail to execute action: 2
2021-12-29 23:35:01.985 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule '915601a534': Fail to execute action: 2
2021-12-29 23:35:01.986 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule '915601a534': Fail to execute action: 2
This is primarily to notify about this behaviour.
Secondly, for me to remedy this situation, is it enough to just manually create these 2 directories?
Think I found the source of my problem.
A year ago I added this:
omr@shs2:~$ ll /etc/openhab/automation/lib/javascript/community/
total 24
drwxr-xr-x 2 root root 4096 Apr 11 2021 ./
drwxr-xr-x 3 root root 4096 Dec 27 2020 ../
-rw-r--r-- 1 root root 5969 Apr 11 2021 timeUtils.js
-rw-r--r-- 1 root root 4199 Dec 27 2020 timerMgr.js
And I had created a /etc/openhab/automation folder without user openhab write access.
Have remedied this now, and after deleting the test rule and creating another one, the rule runs, but with this warning:
2021-12-30 00:02:23.252 [WARN ] [.internal.OpenhabGraalJSScriptEngine] - Failed to retrieve script script dependency listener from engine bindings. Script dependency tracking will be disabled.
2021-12-30 00:02:23.890 [INFO ] [org.openhab.automation.script ] - Ticker 1s
2021-12-30 00:02:24.235 [INFO ] [org.openhab.automation.script ] - Ticker 1s
I looked for a way to Remove the JSScript add-on, but couldn’t find it.
Wanted to re-install with openhab access to the automation directory. Unsure how serious the warning is though.
Edit: was able to remove the JSScript add-on after a karaf bundle uninstall and an openHab restart.
After a remove/re-install, I still get this warning: (but rule is working)
2021-12-30 00:02:23.252 [WARN ] [.internal.OpenhabGraalJSScriptEngine] - Failed to retrieve script script dependency listener from engine bindings. Script dependency tracking will be disabled.