adamrehn / ue4cli

Command-line interface for Unreal Engine 4
https://docs.adamrehn.com/ue4cli/
MIT License
249 stars 45 forks source link

Wrong exit code for unknown reasons #49

Closed tonymrakovcic closed 3 months ago

tonymrakovcic commented 2 years ago

Hello,

I am having a weird problem that I cannot really understand if it's a ue4cli problem, a UE problem or more specifically a UE5 problem I have 2 computers on which I package a plugin.

UE4 -> everything always works on both

UE5 -> on one computer everything works fine, on another, I get the wrong exit code for packaging.

This is a deliberate failed packaging because the problem only happens when the packaging fails (for any reason, let's say syntax error in the code)

The steps to reproduce, with the specific difference between computers:

ue4 setroot to ue5
cd PluginName
ue4 package

Computer 1 Result

Took 157,81171410000002s to run UnrealBuildTool.exe, ExitCode=6
AutomationTool executed for 0h 2m 39s
AutomationTool exiting with ExitCode=6 (6)
BUILD FAILED
Traceback (most recent call last):
  File "C:\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\ue4.exe\__main__.py", line 7, in <module>
  File "C:\Python38\lib\site-packages\ue4cli\cli.py", line 222, in main
    SUPPORTED_COMMANDS[command]['action'](manager, args)
  File "C:\Python38\lib\site-packages\ue4cli\cli.py", line 94, in <lambda>
    'action': lambda m, args: m.packageDescriptor(os.getcwd(), args),
  File "C:\Python38\lib\site-packages\ue4cli\UnrealManagerBase.py", line 476, in packageDescriptor
    self.packagePlugin(dir, args)
  File "C:\Python38\lib\site-packages\ue4cli\UnrealManagerBase.py", line 457, in packagePlugin
    self.runUAT([
  File "C:\Python38\lib\site-packages\ue4cli\UnrealManagerBase.py", line 383, in runUAT
    Utility.run([self.getRunUATScript()] + args, cwd=self.getEngineRoot(), raiseOnError=True)
  File "C:\Python38\lib\site-packages\ue4cli\Utility.py", line 145, in run
    raise Exception('child process ' + str(command) + ' failed with exit code ' + str(returncode))
Exception: child process ['D:\\UE\\UE_5.0\\Engine\\Build\\BatchFiles\\RunUAT.bat', 'BuildPlugin', '-Plugin=D:\\UEprojects\\Project\\Plugins\\PluginName\\plugin.uplugin', '-Package=D:\\UEprojects\\Project\\Plugins\\PluginName\\dist'] failed with exit code 6

(Everything is fine, the packaging failed and we go on with our lives)


ue4 setroot to ue5
cd PluginName
ue4 package

Computer 2 Result

Took 224,4925119s to run UnrealBuildTool.exe, ExitCode=6
UnrealBuildTool failed. See log for more details. (C:\Users\user\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_5.0\UBT-UnrealEditor-Win64-Development.txt)
AutomationTool executed for 0h 3m 54s
AutomationTool exiting with ExitCode=6 (6)
Updating environment variables set by a Turnkey sub-process
The system cannot find the path specified.
The system cannot find the path specified.

(packaging failed, yet we get a exit code 0)


The main problem being the second computer process actually exits with exit code 0 I'm presuming because of the Turnkey sub process. Which in turn really messes up our CI process, since it basically breaks, and continues with the broken build since the CI isn't halted. I cannot seem to reproduce this in computer 1, google doesn't really help and I have not found any project or engine based setting regarding "turnkey" Both are windows 10, ue5 5.0.1 installed from the launcher, ue4cli-0.0.54

Do you have any idea or clue on what would make this different on 2 computers?

tonymrakovcic commented 2 years ago

adding -noturnkeyvariables to ue4 package seems to remove the problem, still not sure why it would be different on 2 comps

sleeptightAnsiC commented 3 months ago

That's seems like an issue with Unreal's RunUAT.bat or Unreal's support for TurnKey.

What ue4 package does on Windows, it simply runs RunUAT.bat subprocess. If said subprocess returns 0 while failing, ue4cli would just behave like if it succeed. There is no way to handle this case, it's not a bug with ue4cli.

The problem that OP encountered on his machine is most likely this one

adamrehn commented 3 months ago

Cross-referencing the details here with those in the linked forum thread, this does indeed appear to be an upstream Unreal Engine issue. Fortunately, it looks like this was fixed in Unreal Engine 5.3.0, and the fix is also trivial to backport to older versions of the engine: https://github.com/EpicGames/UnrealEngine/commit/9cbeb052b3b0d09ad895f5da946e08fb14c34b8f