ID 559759 - Nuke crashes in Terminal mode if a Python script creates a Read node after setting an OCIO config that references non-existent environment variables

Follow

Problem summary:
Nuke crashes in Terminal mode if a Python script creates a Read node after setting an OCIO config that references non-existent environment variables 

Customer reported version:
Nuke 13.2v7
 
Customer reported platform:
Windows 10
 
Steps to reproduce:
1) Download the attached config_with_env_vars.ocio file.
2) Change the following ocio_path variable to the location of the config_with_env_vars.ocio file, and save this code in a .py file named "set_ocio_script.py" (or similar):

# Apply OCIO configocio_path = "path/to/the/config_with_env_vars.ocio"nuke_root = nuke.root()nuke_root.knob("customOCIOConfigPath").setValue(ocio_path)nuke_root.knob("colorManagement").setValue("OCIO")nuke_root.knob("OCIO_config").setValue("custom")nuke_root.knob("reloadConfig").execute()print("Root OCIO knobs set")read = nuke.createNode("Read")print("Read node created")
3) Open Nuke in Terminal mode and execute the set_ocio_script.py file, using a command similar to the following:
"C:\Program Files\Nuke15.0v2\Nuke15.0.exe" -t path/to/the/set_ocio_script.py
4) Observe how Nuke crashes before the "Read node created" message is printed to the Terminal:

 
Expected behavior:
When a Python script sets the Root node to use a custom OCIO config that references non-existent environment variables, it should still be possible to create a Read node without Nuke crashing.
 
Actual behavior:
After launching Nuke in Terminal mode and running a Python script to set the Root's customOCIOConfigPath knob to an OCIO config with missing environment variables, creating a Read node causes Nuke to crash.
 
If the set_ocio_script.py code is run in the Script Editor window after Nuke was launched from the GUI, a crash does not occur, but the following error is printed to the Error Console:
ERROR: oCIODisplay: The specified file reference '$<environment_variable>.cc' could not be located.

 
If Nuke is launched in Terminal mode and the set_ocio_script.py script is manually run line-by-line, the crash does not seem to occur:

 
Workaround:
Placing knobDefault code inside the ~/.nuke/init.py file to set the Root's OCIO knobs appears to prevent the crash:
ocio_path = "path/to/the/custom/config_with_env_vars.ocio" nuke.knobDefault("Root.customOCIOConfigPath",ocio_path) nuke.knobDefault("Root.colorManagement","OCIO") nuke.knobDefault("Root.OCIO_config","custom")
In which case, the set_ocio_script.py should be updated to look similar to the following: 
read = nuke.createNode("Read") print("Read node created")
 
Reproduced by Support in:
Nuke 15.0v2 - Windows 10, macOS 13 Ventura
Nuke 14.0v1 - Windows 10
Nuke 13.1v1 - Windows 10 - Regression
 
Unable to reproduce bug in:
Nuke 13.0v10 - Windows 10
 
Earliest version tested:
Nuke 13.0v10 - This issue doesn't appear in this version and has regressed 

    We're sorry to hear that

    Please tell us why