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' PC export when std::fs::copy fails while copying the game binary or its dependencies into the destination export folder. Like the Android variant, it is non-fatal but leaves the export incomplete. The io::Error is included in the message.
Solutions
- Close the running game instance that locks the destination binary
- Create the destination folder with fs::create_dir_all before exporting
- Run the export with write permission for the destination (avoid copying into protected system dirs)
- Whitelist the build/export directory in antivirus software and retry
Example fix
// before
Log::warn(format!("Failed to copy {} ...", path.display()));
// after
fs::create_dir_all(&destination_folder)?;
fs::copy(&path, &dst).map_err(|e| anyhow!("copy {} -> {}: {e}", path.display(), dst.display()))?; Defensive patterns
Strategy: fallback
Validate before calling
assert!(path.is_file(), "source binary missing: {}", path.display());
fs::create_dir_all(&destination_folder)?; Try / catch
fs::copy(&path, &dst).or_else(|e| {
Log::warn(format!("copy {} failed: {e}", path.display()));
Err(e)
})?; Prevention
- Stop the game process before overwriting its exe
- Create destination directories up front
- Retry copy once on transient locks (antivirus)
When it happens
Trigger: copy_binaries in fyrox-build-tools/src/export/pc.rs calls fs::copy for each discovered binary; the Err arm logs this with path, destination folder, and error.
Common situations: Destination exe locked because the game is still running, destination folder missing, permission denied in Program Files-like locations, antivirus quarantining the freshly built exe.
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
- Failed to copy file to the folder. Reason
- unknown target platform
- Attempt to get reference to resource data which failed to…
- Invalid path
- An error occurred when reading data from socket
AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10).
Data as JSON: /api/errors/13ae6a23416c943f.
Report an issue: GitHub.
Appendix: source
Thrown at fyrox-build-tools/src/export/pc.rs:75
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(destination_folder: &Path, package_name: &str) {
#[allow(unused_mut)]
let mut path = destination_folder.join(package_name);
#[cfg(windows)]
{View on GitHub (pinned to 76c91aad8e)