Add error message when trying to load project from CWD.

This commit is contained in:
Pāvels Nadtočajevs 2025-11-16 10:09:23 +02:00
parent 8deb221829
commit a7358ddd12
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
7 changed files with 43 additions and 2 deletions

View file

@ -992,6 +992,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->initialize();
#if !defined(OVERRIDE_PATH_ENABLED) && !defined(TOOLS_ENABLED)
String old_cwd = OS::get_singleton()->get_cwd();
#ifdef MACOS_ENABLED
String new_cwd = OS::get_singleton()->get_bundle_resource_dir();
if (new_cwd.is_empty() || !new_cwd.is_absolute_path()) {
@ -2019,8 +2020,23 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#ifdef TOOLS_ENABLED
editor = false;
#else
const String error_msg = "Error: Couldn't load project data at path \"" + project_path + "\". Is the .pck file missing?\nIf you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).\n";
OS::get_singleton()->print("%s", error_msg.utf8().get_data());
String error_msg = "Error: Couldn't load project data at path \"" + (project_path == "." ? OS::get_singleton()->get_cwd() : project_path) + "\". Is the .pck file missing?\n\n";
#if !defined(OVERRIDE_PATH_ENABLED) && !defined(TOOLS_ENABLED)
String exec_path = OS::get_singleton()->get_executable_path();
String exec_basename = exec_path.get_file().get_basename();
if (FileAccess::exists(old_cwd.path_join(exec_basename + ".pck"))) {
error_msg += "\"" + exec_basename + ".pck\" was found in the current working directory. To be able to load a project from the CWD, use the `disable_path_overrides=no` SCons option when compiling Godot.\n";
} else if (FileAccess::exists(old_cwd.path_join("project.godot"))) {
error_msg += "\"project.godot\" was found in the current working directory. To be able to load a project from the CWD, use the `disable_path_overrides=no` SCons option when compiling Godot.\n";
} else {
error_msg += "If you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).\n";
}
#else
error_msg += "If you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).\n";
#endif
ERR_PRINT(error_msg);
OS::get_singleton()->alert(error_msg);
goto error;