FyroxEngine/Fyrox · warning

Failed to copy file to the folder. Reason

Error message

Failed to copy {} file to the {} folder. Reason: {:?}

What it means

Logged warning in fyrox-build-tools' Android export when std::fs::copy fails while copying a binary (e.g. the game executable or .so) into the Android export folder. The export continues but the built artifact will be incomplete. It is a non-fatal, logged warning rather than a panic.

Solutions

  1. Create the destination folder (fs::create_dir_all) before calling copy_binaries
  2. Verify the source binary path exists after the cargo/gradle build completes
  3. Check write permissions on the Android export data folder and free disk space
  4. Rebuild the project so the source binary is regenerated, then re-run the export

Example fix

// before
fs::copy(&path, &dst_path).unwrap();
// after
fs::create_dir_all(&destination_folder)?;
match fs::copy(&path, &dst_path) {
    Ok(_) => Log::info(format!("Copied {}", path.display())),
    Err(e) => Log::warn(format!("Copy failed: {e}")),
}
Defensive patterns

Strategy: fallback

Validate before calling

if !path.exists() { eprintln!("skip missing {}", path.display()); }
if !destination_folder.exists() { fs::create_dir_all(&destination_folder)?; }

Type guard

fn copyable(src: &Path, dst: &Path) -> bool { src.is_file() && dst.is_dir() || fs::create_dir_all(dst).is_ok() }

Try / catch

match fs::copy(&path, &dst) {
    Ok(_) => {},
    Err(e) if e.kind() == ErrorKind::PermissionDenied => return Err(e.into()),
    Err(e) => Log::warn(format!("copy failed: {e}")),
}

Prevention

When it happens

Trigger: copy_binaries on fyrox-build-tools/src/export/android.rs iterates source files and calls fs::copy; the Err arm logs this message with the source path, destination folder, and the io::Error.

Common situations: Source binary missing or deleted after build, destination folder does not exist or lacks write permission, file locked by antivirus/another process, cross-device copy, disk full.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10). Data as JSON: /api/errors/7f93f6b0339306b5. Report an issue: GitHub.

Appendix: source

Thrown at fyrox-build-tools/src/export/android.rs:87

        if let Some(stem) = entry.path().file_stem() {
            if stem == OsStr::new(package_name) {
                binary_paths.push(entry.path());
            }
        }
    }
    for path in binary_paths {
        if let Some(file_name) = path.file_name() {
            match fs::copy(&path, destination_folder.join(file_name)) {
                Ok(_) => {
                    Log::info(format!(
                        "{} was successfully copied to the {} folder.",
                        path.display(),
                        destination_folder.display()
                    ));
                }
                Err(err) => {
                    Log::warn(format!(
                        "Failed to copy {} file to the {} folder. Reason: {:?}",
                        path.display(),
                        destination_folder.display(),
                        err
                    ));
                }
            }
        }
    }

    Ok(())
}

pub fn run_build(package_name: &str, destination_folder: &Path) {
    if let Ok(adb) = utils::make_command("adb")
        .current_dir(destination_folder)
        .arg("install")
        .arg(format!("{package_name}.apk"))

View on GitHub (pinned to 76c91aad8e)