nikivdev/code · error
No templates found in ~/new/
Error message
No templates found in ~/new/
What it means
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.
Source
Thrown at src/code.rs:60
let entry = entry?;
let path = entry.path();
if path.is_dir() {
if let Some(name) = path.file_name().and_then(|n| n.to_str()) {
if !name.starts_with('.') {
templates.push(name.to_string());
}
}
}
}
templates.sort();
Ok(templates)
}
/// Fuzzy select a template from ~/new/.
fn fuzzy_select_template() -> Result<Option<String>> {
let templates = list_templates()?;
if templates.is_empty() {
bail!("No templates found in ~/new/");
}
let input = templates.join("\n");
let mut fzf = Command::new("fzf")
.args(["--height=50%", "--reverse", "--prompt=Template: "])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.context("failed to spawn fzf")?;
fzf.stdin.as_mut().unwrap().write_all(input.as_bytes())?;
let output = fzf.wait_with_output()?;
if !output.status.success() {
return Ok(None);
}
View on GitHub (pinned to a747e741ae)
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/.
Example fix
// before $ f new Error: No templates found in ~/new/ // after $ mkdir -p ~/new/rust-cli && cp -r myproject/. ~/new/rust-cli/ $ f new # fzf picker opens
Defensive patterns
Strategy: validation
Validate before calling
// Shell: ensure the template root has at least one template
[ -d "$HOME/new" ] && [ -n "$(ls -A "$HOME/new" 2>/dev/null)" ] \
|| { echo "~/new/ is empty; add a template dir first"; exit 1; } Try / catch
match new_from_template(opts) {
Err(e) if e.to_string().contains("No templates found") => {
eprintln!("Create ~/new/<template>/ first, or pass a template name explicitly.");
}
other => other?,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- enable-global is only supported for Codex sessions; use `f c
- fzf not found – install it for fuzzy selection
- Project mismatch. Bundle is for '{}' but this repo is '{}'.
- Diff bundle not found. Expected {} or pass a path to a bundl
- Template not found: {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/3eb3852754cd2aa8.
Report an issue: GitHub.