{"record":{"id":"8aecbe75285cff6f","repo":"nikivdev/code","slug":"template-not-found","errorCode":null,"errorMessage":"Template not found: {}","messagePattern":"Template not found: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/code.rs","lineNumber":104,"sourceCode":"\n/// Create a new project from a template at a specific path.\n/// Usage: f new [template] [path]\npub fn new_from_template(opts: NewOpts) -> Result<()> {\n    let template_root = config::expand_path(DEFAULT_TEMPLATE_ROOT);\n\n    // Get template name (fuzzy select if not provided)\n    let template_name = match opts.template {\n        Some(t) => t,\n        None => match fuzzy_select_template()? {\n            Some(t) => t,\n            None => return Ok(()), // User cancelled\n        },\n    };\n\n    let template_dir = template_root.join(template_name.trim());\n\n    if !template_dir.exists() {\n        bail!(\"Template not found: {}\", template_dir.display());\n    }\n    if !template_dir.is_dir() {\n        bail!(\n            \"Template path is not a directory: {}\",\n            template_dir.display()\n        );\n    }\n\n    // Resolve target path:\n    // - No path: ./<template_name>\n    // - Starts with ./ or ../: relative to cwd\n    // - Starts with ~ or /: absolute path\n    // - Otherwise: relative to ~/code/\n    let target = match opts.path {\n        None => std::env::current_dir()?.join(&template_name),\n        Some(p) => {\n            let trimmed = p.trim();\n            if trimmed.starts_with(\"./\")","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/code.rs#L86-L122","documentation":"Thrown by new_from_template (src/code.rs:104) when the explicitly supplied template name does not correspond to an existing entry under ~/new/. The error prints the fully joined path so the exact location checked is visible.","triggerScenarios":"Running `f new <template> <path>` where expand_path(~/new).join(template) does not exist — wrong name, wrong case, template deleted, or trailing whitespace already handled via trim().","commonSituations":"Typo in the template name; template directory renamed after docs/scripts referenced it; running on a machine that never received the template; case-sensitivity on Linux (MyTemplate vs mytemplate).","solutions":["Run `ls ~/new` and use the exact template directory name shown.","Create the missing template directory: `mkdir -p ~/new/<name>`.","Omit the template argument (`f new`) to pick interactively from existing templates.","Check for case/whitespace differences in the name you passed."],"exampleFix":"// before\n$ f new rust_clib ~/code/proj\nError: Template not found: /home/user/new/rust_clib\n// after\n$ ls ~/new   # shows rust-cli\n$ f new rust-cli ~/code/proj","handlingStrategy":"validation","validationCode":"// Shell: confirm the template exists before invoking\nTPL=\"$HOME/new/$TEMPLATE_NAME\"\n[ -d \"$TPL\" ] || { echo \"template missing: $TPL; available:\"; ls \"$HOME/new\"; exit 1; }","typeGuard":"fn template_exists(name: &str) -> bool {\n    config::expand_path(\"~/new\").join(name.trim()).is_dir()\n}","tryCatchPattern":"match new_from_template(opts) {\n    Err(e) if e.to_string().contains(\"Template not found\") => {\n        eprintln!(\"Unknown template; run `ls ~/new` for available templates.\");\n    }\n    other => other?,\n}","preventionTips":["Keep a canonical list of template names and validate against it in scripts","Use tab-completion or `ls ~/new` rather than typing template names from memory","Note Linux path names are case-sensitive; prefer lowercase template dirs"],"tags":["file-not-found","cli","rust","argument-error"],"backgroundTag":"template-not-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}