{"record":{"id":"3eb3852754cd2aa8","repo":"nikivdev/code","slug":"no-templates-found-in-new","errorCode":null,"errorMessage":"No templates found in ~/new/","messagePattern":"No templates found in ~/new/","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/code.rs","lineNumber":60,"sourceCode":"        let entry = entry?;\n        let path = entry.path();\n        if path.is_dir() {\n            if let Some(name) = path.file_name().and_then(|n| n.to_str()) {\n                if !name.starts_with('.') {\n                    templates.push(name.to_string());\n                }\n            }\n        }\n    }\n    templates.sort();\n    Ok(templates)\n}\n\n/// Fuzzy select a template from ~/new/.\nfn fuzzy_select_template() -> Result<Option<String>> {\n    let templates = list_templates()?;\n    if templates.is_empty() {\n        bail!(\"No templates found in ~/new/\");\n    }\n\n    let input = templates.join(\"\\n\");\n\n    let mut fzf = Command::new(\"fzf\")\n        .args([\"--height=50%\", \"--reverse\", \"--prompt=Template: \"])\n        .stdin(Stdio::piped())\n        .stdout(Stdio::piped())\n        .spawn()\n        .context(\"failed to spawn fzf\")?;\n\n    fzf.stdin.as_mut().unwrap().write_all(input.as_bytes())?;\n\n    let output = fzf.wait_with_output()?;\n    if !output.status.success() {\n        return Ok(None);\n    }\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/code.rs#L42-L78","documentation":"Thrown by fuzzy_select_template (src/code.rs:60) when `f new` is run without a template argument and no template directories exist under ~/new/. list_templates() only counts non-hidden subdirectories of ~/new/, so an empty or missing ~/new/ yields zero templates and this bail instead of opening fzf.","triggerScenarios":"Running `f new` (no template arg) via new_from_template -> fuzzy_select_template when ~/new/ does not exist, is empty, or contains only hidden/regular-file entries.","commonSituations":"Fresh machine where the template root was never set up; HOME misconfigured so ~/new/ resolves to the wrong location; templates stored elsewhere; templates accidentally flattened into files instead of directories.","solutions":["Create the template root and add at least one template directory: `mkdir -p ~/new/rust-cli`.","Pass a template name explicitly (`f new rust-cli ~/code/myproj`) to bypass fuzzy selection entirely.","Verify ~/new/ resolves to the right place (`echo $HOME; ls ~/new`) and fix $HOME if wrong.","If your templates live elsewhere, move/symlink them into ~/new/."],"exampleFix":"// before\n$ f new\nError: No templates found in ~/new/\n// after\n$ mkdir -p ~/new/rust-cli && cp -r myproject/. ~/new/rust-cli/\n$ f new  # fzf picker opens","handlingStrategy":"validation","validationCode":"// Shell: ensure the template root has at least one template\n[ -d \"$HOME/new\" ] && [ -n \"$(ls -A \"$HOME/new\" 2>/dev/null)\" ] \\\n  || { echo \"~/new/ is empty; add a template dir first\"; exit 1; }","typeGuard":null,"tryCatchPattern":"match new_from_template(opts) {\n    Err(e) if e.to_string().contains(\"No templates found\") => {\n        eprintln!(\"Create ~/new/<template>/ first, or pass a template name explicitly.\");\n    }\n    other => other?,\n}","preventionTips":["Bootstrap ~/new/ with at least one template directory on every new machine","Always pass a template name in scripts instead of relying on the fzf picker","Verify $HOME points where you expect when using dotfiles managers"],"tags":["missing-directory","cli","rust","fzf"],"backgroundTag":"missing-template-root","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}