[BUG-13425] NameError: global name 'shared' is not defined

I’ve been holding off posting this bug for a while because it seems to occur (and resolve) at random, but it has really become quite a problem.

Our main project originally had a script package called ‘shared’, but after an update this ‘shared’ package became part of a new parent project (global) and our main project automatically became a child of global.

Our main project has a script package called ‘project’. This package has a handful of scripts, some of which make calls to functions defined in the ‘shared’ package. All our scripts seem to be working except one called ‘webservice’.

Steps to reproduce the error:

  • some kind of project restart has to be done, not sure exactly what yet
  • onClick of a button calls project.webservice.test(), which simply calls shared.logConst.LOGOUT (but this could be shared.<any_script>.<any_function_or_constant>). This gives the error.
  • some kind of change has to be done. yesterday we copied ‘webservice’ to a new script, deleted ‘webservice’, and renamed the new script to be ‘webservice’, which worked. Today the same error occurred so we duplicated the project.webservice.test() function to project.videsDbFunctions.test(). videsDbFunctions already makes references to ‘shared’ without error so we expected this test to pass as well which it did BUT this also caused project.webservice.test() to start working. After reverting the change (ie removing test() from videsDbFunctions), webservice.test() still ran without errors.
    Restarting the Designer did not bring the error back.
    Restarting the Gateway did not bring the error back.

However, much like yesterday and many times before, I’m sure that at some point the error will reoccur.

STACK TRACE:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 8, in runAction File “”, line 158, in test NameError: global name ‘shared’ is not defined

at org.python.core.Py.NameError(Py.java:290)

at org.python.core.PyFrame.getglobal(PyFrame.java:265)

at org.python.pycode._pyx574.test$8(:158)

at org.python.pycode._pyx574.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:171)

at org.python.core.PyBaseCode.call(PyBaseCode.java:125)

at org.python.core.PyFunction.call(PyFunction.java:403)

at org.python.pycode._pyx573.runAction$1(:10)

at org.python.pycode._pyx573.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:171)

at org.python.core.PyBaseCode.call(PyBaseCode.java:308)

at org.python.core.PyFunction.function___call__(PyFunction.java:471)

at org.python.core.PyFunction.call(PyFunction.java:466)

at org.python.core.PyFunction.call(PyFunction.java:456)

at org.python.core.PyFunction.call(PyFunction.java:451)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:702)

at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:820)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:575)

at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:82)

at com.inductiveautomation.perspective.gateway.action.ScriptAction.runAction(ScriptAction.java:65)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.lambda$call$0(ActionCollection.java:257)

at com.inductiveautomation.perspective.gateway.api.LoggingContext.mdc(LoggingContext.java:54)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:246)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:215)

at com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue$TaskWrapper.run(BlockingTaskQueue.java:154)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: Traceback (most recent call last): File “”, line 8, in runAction File “”, line 158, in test NameError: global name ‘shared’ is not defined

… 30 common frames omitted

Any chance I could see your “test” script, either here in the thread or through Direct Message?

Thanks, I think I’ve reproduced this.

def test():
shared.logConst.LOGOUT

That’s the script (tabs aren’t displayed in the forum post) that is giving an error in project.webservice but not giving an error in project.videsDbFunctions or any other project scripts.

I can send full scripts/files if you want, though it sounds like Kevin was able to reproduce the bug

Hi Kevin,
With the full release of Ignition 8 we are still seeing the same issue.
You mentioned you had been able to reproduce the issue, just wondering what the plan for fixes is now that the product it out of Beta? Is there some cadence to 8.0.xx releases we can expect?

Thanks

Every ~4 weeks there should be a new release. We're also going to continue doing nightly releases in between those 4 week releases.

Blog post about it: All Aboard the Release Train. First Stop: Ignition 8! | Inductive Automation

Thanks, that is helpful information.
Specifically regarding this issue, it is a show stopper for us.
Our project development is essentially complete and we are going through testing and acceptance.
The way this is occurring the project just becomes nonfunctional multiple times through the day.

Basically our project will have to hold any go-live until this is resolved. Can you confirm it is being addressed for the next build release?

It hasn’t been officially assigned yet but it should get fixed for 8.0.1 unless for some reason we can’t figure it out in time.

Almost the same here, this is blocking our development and we need a solution quite soon.
@Kevin.Herron: When will 8.0.1 be released and when will you know if this fix will be included?

This should be fixed in the nightly builds from yesterday and today.

8.0.1-rc1 will be released Monday and 8.0.1 final another week after that.

I believe this might still be an issue? Unless it’s unrelated but similar.

I upgraded from 8.0.0 to 8.0.1-rc1 and my scrips stopped working and weren’t being recognized until I went into each, changed a line, and saved the project.

Just FYI you can preserve formatting using the 'preformated text' button (image ) or enclose your textblock with three tilde characters either side ```:

def test():
	shared.logConst.LOGOUT
1 Like