Skip to content
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

Exit code 1 after importing in headless mode with --quit #83449

Closed
InfinitiesLoop opened this issue Oct 16, 2023 · 3 comments · Fixed by #89229
Closed

Exit code 1 after importing in headless mode with --quit #83449

InfinitiesLoop opened this issue Oct 16, 2023 · 3 comments · Fixed by #89229

Comments

@InfinitiesLoop
Copy link

Godot version

v4.1.1.stable.official [bd6af8e]

System information

macOS 13.0.1 - Vulkan (Mobile) - integrated Apple M1 Max - Apple M1 Max (10 Threads)

Issue description

When running godot in headless mode to import a project for the first time (no .godot folder yet), it seems to succeed in that there are no errors, but the exit code is 1. This causes CI actions (e.g. a github action) to assume the step failed, preventing us from being able to produce exports as part of CI. For example, when using this github action, it will fail since it can't get passed the import step: https://github.com/marketplace/actions/godot-export

dreed ~/git/GodotTest
$ rm -rf .godot/

dreed ~/git/GodotTest
$ g project.godot --headless -e --quit
Godot Engine v4.1.1.stable.official.bd6af8e0e - https://godotengine.org

WARNING: Custom cursor shape not supported by this display server.
     at: cursor_set_custom_image (servers/display_server.cpp:480)
WARNING: Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported.
     at: _editor_init (modules/gltf/register_types.cpp:73)

dreed ~/git/GodotTest
$ echo $?
1

Steps to reproduce

  1. Create a new blank project on MacOS with Godot 4.1.x
  2. Close the Godot editor
  3. Delete the .godot folder
  4. Run godot in headless mode with -e --quit: godot project.godot --headless -e --quit
  5. Echo the exit code with echo $?
  6. --> Exit code is 1 even though there were no apparent errors

I tried this with --verbose as well and there's a lot more info provided, but still nothing that looks like an error or even a warning.

Minimal reproduction project

GodotTest.zip

@Calinou
Copy link
Member

Calinou commented Oct 16, 2023

This doesn't occur on my end with 4.2.dev 42425ba (Linux) when using --quit on the project manager or editor on a project, regardless of whether it already has a .godot/ folder or not.

Commands I've tried:

godot --quit
godot --quit /tmp/4/project.godot --editor  # `--editor/-e` is implied when specifying a path to `project.godot`.
godot --quit /tmp/4/project.godot
godot --quit --path /tmp/4/ --editor
godot --headless --quit
godot --headless --quit /tmp/4/project.godot --editor  # `--editor/-e` is implied when specifying a path to `project.godot`.
godot --headless --quit /tmp/4/project.godot
godot --headless --quit --path /tmp/4/ --editor

To check for the origin of the exit code, I recommend searching for instances of set_exit_code(, quit( and _exit_editor( in the codebase.

@InfinitiesLoop
Copy link
Author

InfinitiesLoop commented Oct 16, 2023

I believe the platform matters. It maybe specific to MacOS Godot. CI that needs to sign exports with xcode need to be on a Mac (if I am not mistaken), so not easy to work around.

@InfinitiesLoop
Copy link
Author

InfinitiesLoop commented Oct 17, 2023

I added logging to OS::set_exit_code and SceneTree::exit, nothing ever calls it on this code path. So I believe it is using exit code 1 simply because it's the default value and nothing ever sets it:

int _exit_code = EXIT_FAILURE; // unexpected exit is marked as failure

I don't know the code well enough to know where/what should be setting EXIT_SUCCESS, unless someone has an idea I'd be happy to submit a PR

Edit: It would seem it simply needs to be set explicitly prior to setting exit = true in main. All other code paths set the exit code explicitly, only this one didn't. I have submitted a PR

InfinitiesLoop added a commit to InfinitiesLoop/godot that referenced this issue Oct 17, 2023
The default exit code is EXIT_FAILURE. When using --quit and there is no failure, it should be EXIT_SUCCESS.

Fixes godotengine#83449
dreed-sd added a commit to dreed-sd/godot-export that referenced this issue Oct 19, 2023
Godot 4.1.x has exit code 1 on MacOS currently. That causes the import step to fail.
This provides a workaround until this is fixed, and if it ever happens again. There may also
be other scenarios where it's better to keep going, such as if an export preset fails, to continue
to try the next export preset.

See godotengine/godot#83449
dreed-sd added a commit to dreed-sd/godot-export that referenced this issue Oct 19, 2023
Godot 4.1.x has exit code 1 on MacOS currently. That causes the import step to fail.
This provides a workaround until this is fixed, and if it ever happens again. There may also
be other scenarios where it's better to keep going, such as if an export preset fails, to continue
to try the next export preset.

See godotengine/godot#83449
@akien-mga akien-mga added this to the 4.3 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants