godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.13k stars 21.19k forks source link

Headless export fails due to missing directory in .godot #72360

Closed f8122dac91 closed 1 year ago

f8122dac91 commented 1 year ago

Godot version

4.0.beta16

System information

Linux.x86_64

Issue description

Running the following command to export a freshly pulled git repository:

<Godot_v4.0-beta16_linux.x86_64_BINARY_PATH> \
    --headless \
    --export-debug Linux/X11 \
    ./project.godot <SOME_EXPORT_PATH>

fails to export proper artifacts and reports errors due to res://.godot/imported and res://.godot/editor being unavailable. I suspect that the execution of --export somehow assumes these directories exists, while the template .gitignore excludes .godot/.

Example errors:

ERROR: Cannot save editor settings to file 'res://.godot/editor/project_metadata.cfg'.
   at: set_project_metadata (editor/editor_settings.cpp:1127)
ERROR: Cannot save editor settings to file 'res://.godot/editor/project_metadata.cfg'.
   at: set_project_metadata (editor/editor_settings.cpp:1127)
ERROR: Cannot save editor settings to file 'res://.godot/editor/project_metadata.cfg'.
   at: set_project_metadata (editor/editor_settings.cpp:1127)
reimport: begin: (Re)Importing Assets steps: 1
    reimport: step 0: icon.svg
ERROR: Condition "f.is_null()" is true.
   at: _save_ctex (editor/import/resource_importer_texture.cpp:336)
ERROR: Cannot open MD5 file 'res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.md5'.
   at: _reimport_file (editor/editor_file_system.cpp:2100)
ERROR: Cannot create file 'res://.godot/editor/filesystem_cache8'. Check user write permissions.
   at: _save_filesystem_cache (editor/editor_file_system.cpp:348)
savepack: begin: Packing steps: 102
ERROR: Can't open file from path 'res://.godot/global_script_class_cache.cfg'.
   at: get_file_as_bytes (core/io/file_access.cpp:699)
    savepack: step 2: Storing File: res://.godot/global_script_class_cache.cfg
ERROR: Can't open file from path 'res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex'.
   at: get_file_as_bytes (core/io/file_access.cpp:699)
    savepack: step 35: Storing File: res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex
    savepack: step 35: Storing File: res://icon.svg.import
    savepack: step 68: Storing File: res://.godot/exported/133200997/export-5c1b5421b3a3843354800198f9326b19-node.scn
    savepack: step 102: Storing File: res://node.tscn.remap
    savepack: step 102: Storing File: res://icon.svg
    savepack: step 102: Storing File: res://.godot/uid_cache.bin
    savepack: step 102: Storing File: res://project.binary
savepack: end
reimport: end
ERROR: Cannot create file 'res://.godot/editor/filesystem_cache8'. Check user write permissions.

Since the provided .gitignore template for a new project contains .godot/, most of the git repositories does not commit this directory, so running export command against a freshly pulled repositories will most likely to fail.

These locations do get created on the first time GUI editor loads the project. However, for the environment that cannot load the GUI editor, e.g. containers for CI pipeline (which is what I was trying to do), export functionality from commandline won't work properly.

Workaround I Found for Now

I tried again after manually creating these two directory .godot/{imported,editor}, and the export succeeded.

Steps to reproduce

  1. Create a new minimal project with a main scene selected so that it can be exported.
  2. Remove .godot/ directory.
  3. run export command: <Godot_v4.0-beta16_linux.x86_64_BINARY_PATH> --headless --export-debug Linux/X11 ./project.godot <SOME_EXPORT_PATH>

Minimal reproduction project

minimal-project.zip

lyuma commented 1 year ago

In V-Sekai, we found that we were able to workaround this issue and produce successful exports by running mkdir -p .godot/editor .godot/imported before attempting the headless export.

I would propose we automatically make these two directories very early when starting the editor, perhaps in Main::start

output log from bad build with no .godot folder.

reimport: begin: (Re)Importing Assets steps: 321
        reimport: step 0: vr_manager_strings.csv
ERROR: Cannot create file 'res://.godot/editor/filesystem_update4'. Check user write permissions.
   at: (editor/editor_file_system.cpp:1484)
SCRIPT ERROR: Compile Error: Identifier not found: EntityManager
          at: GDScript::reload (res://addons/actor/player_controller.gd:292)
SCRIPT ERROR: Parse Error: Identifier "GameManager" not declared in the current scope.
          at: GDScript::reload (res://net_demo/core/physics_object_multiplayer_synchronizer.gd:47)
ERROR: Cannot open MD5 file 'res://.godot/imported/vr_manager_strings.csv-aa4d36bad71565d78cabb2615439ceb3.md5'.
   at: (editor/editor_file_system.cpp:2144)
        reimport: step 1: menu_strings.csv
ERROR: Cannot create file 'res://.godot/editor/filesystem_update4'. Check user write permissions.
   at: (editor/editor_file_system.cpp:1484)
ERROR: Cannot create file 'res://.godot/editor/filesystem_update4'. Check user write permissions.
   at: (editor/editor_file_system.cpp:1484)
ERROR: Cannot open MD5 file 'res://.godot/imported/menu_strings.csv-40dd836640f634db9f72d88a2339a46a.md5'.
   at: (editor/editor_file_system.cpp:2144)
        reimport: step 2: roboto_mono_bold.ttf
ERROR: Cannot create file 'res://.godot/imported/roboto_mono_bold.ttf-4dc3641157d1c3625a7b2443555e60b1.fontdata'.
   at: (core/io/resource_format_binary.cpp:2121)
ERROR: Cannot save font to file "res://.godot/imported/roboto_mono_bold.ttf-4dc3641157d1c3625a7b2443555e60b1.res".
   at: (editor/import/resource_importer_dynamic_font.cpp:229)
ERROR: Error importing 'res://addons/emote_theme/fonts/roboto_mono_bold.ttf'.
   at: (editor/editor_file_system.cpp:2023)

Output log from a good build if I created .godot/imported and .godot/editor:

ERROR: Cannot open file 'res://.godot/imported/xbot.vrm-bdee71d873ffea966b27e308ff38241f.scn'.
   at: (core/io/resource_format_binary.cpp:1292)
reimport: begin: (Re)Importing Assets steps: 321
        reimport: step 0: vr_manager_strings.csv
SCRIPT ERROR: Compile Error: Identifier not found: EntityManager
          at: GDScript::reload (res://addons/actor/player_controller.gd:292)
SCRIPT ERROR: Parse Error: Identifier "GameManager" not declared in the current scope.
          at: GDScript::reload (res://net_demo/core/physics_object_multiplayer_synchronizer.gd:47)
        reimport: step 1: menu_strings.csv
        reimport: step 2: roboto_mono_bold.ttf
        reimport: step 3: roboto_mono_bold_italic.ttf
        reimport: step 4: roboto_mono_italic.ttf
        reimport: step 5: roboto_mono_regular.ttf
        reimport: step 6: splash.png

(The GDScript errors are normal in my project and not related to this issue. Just left them in the log so I could compare.)