{"record":{"id":"90b0a5d4ea91d772","repo":"tauri-apps/tauri","slug":"source-does-not-exist","errorCode":null,"errorMessage":"source does not exist","messagePattern":"source does not exist","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri-cli/src/helpers/fs.rs","lineNumber":18,"sourceCode":"// Copyright 2019-2024 Tauri Programme within The Commons Conservancy\n// SPDX-License-Identifier: Apache-2.0\n// SPDX-License-Identifier: MIT\n\nuse crate::{\n  error::{Context, ErrorExt},\n  Error,\n};\nuse std::path::{Path, PathBuf};\n\npub fn copy_file(from: impl AsRef<Path>, to: impl AsRef<Path>) -> crate::Result<()> {\n  let from = from.as_ref();\n  let to = to.as_ref();\n  if !from.exists() {\n    Err(Error::Fs {\n      context: \"failed to copy file\",\n      path: from.to_path_buf(),\n      error: std::io::Error::new(std::io::ErrorKind::NotFound, \"source does not exist\"),\n    })?;\n  }\n  if !from.is_file() {\n    Err(Error::Fs {\n      context: \"failed to copy file\",\n      path: from.to_path_buf(),\n      error: std::io::Error::other(\"not a file\"),\n    })?;\n  }\n  let dest_dir = to.parent().expect(\"No data in parent\");\n  std::fs::create_dir_all(dest_dir)\n    .fs_context(\"failed to create directory\", dest_dir.to_path_buf())?;\n  std::fs::copy(from, to).fs_context(\"failed to copy file\", from.to_path_buf())?;\n  Ok(())\n}\n\n/// Find an entry in a directory matching a glob pattern.\n/// Currently does not traverse subdirectories.","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-cli/src/helpers/fs.rs#L1-L36","documentation":"tauri-cli's copy_file helper guards every copy by first checking from.exists(); when the source path is missing it returns Error::Fs with context 'failed to copy file', the offending path, and an inner NotFound io::Error ('source does not exist'). The check exists to fail fast with a precise path instead of letting a raw OS error surface later.","triggerScenarios":"Any tauri-cli/bundler code path that copies a declared file — icons, license files, templates, generated artifacts — where the source was deleted, misnamed, or never created by the step that was supposed to generate it. Note the exists() check is also a TOCTOU race: a file removed between check and copy still yields a raw OS error.","commonSituations":"Case-sensitivity mismatches that work on macOS/Windows but fail on Linux CI (Icon.png vs icon.png); paths pointing at files removed by cargo clean or excluded via gitignore; a codegen step skipped because an earlier command failed; stale config after a file rename.","solutions":["Compare the exact `path` field in the error against the filesystem, checking character case on Linux","Fix the case or spelling in tauri.conf.json / code so it matches the real file","If the file is generated, make sure the generating step runs and succeeds before the copy","Re-run `tauri icon` or the codegen command, or restore the deleted file, then rebuild"],"exampleFix":"// before (tauri.conf.json): \"licenseFile\": \"./LICENCE\"  // actual file: LICENSE\n// after:\n\"licenseFile\": \"./LICENSE\"","handlingStrategy":"validation","validationCode":"// Rust callers: verify source before copying\nfn safe_copy(from: &std::path::Path, to: &std::path::Path) -> std::io::Result<u64> {\n    let meta = std::fs::metadata(from)\n        .map_err(|e| std::io::Error::new(e.kind(), format!(\"missing source {from:?}: {e}\")))?;\n    if !meta.is_file() {\n        return Err(std::io::Error::other(format!(\"{from:?} is not a regular file\")));\n    }\n    if let Some(dir) = to.parent() { std::fs::create_dir_all(dir)?; }\n    std::fs::copy(from, to)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Develop on a case-sensitive filesystem (or run CI on Linux) to catch path-case mismatches early","Make codegen steps fail loudly so missing artifacts are caught before copies","After renaming files, grep tauri.conf.json and code for stale paths"],"tags":["filesystem","copy","file-not-found","cli"],"backgroundTag":"file-not-found","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}