zed-industries/zed · error
Failed to read prompt
Error message
Failed to read prompt
What it means
A guard on the dynamic-prompts path only: when the dynamic_prompts feature is enabled, get_prompt reads the prompt template file from src/prompts/<name> at runtime and this expect fires if fs::read fails — missing prompt file, wrong name, unreadable permissions, or the binary running from a tree where CARGO_MANIFEST_DIR content is absent. The .context(name) wraps the io::Error so the panic names the offending prompt file.
Source
Thrown at crates/edit_prediction_cli/src/prompt_assets.rs:21
#[cfg(feature = "dynamic_prompts")]
pub fn get_prompt(name: &'static str) -> Cow<'static, str> {
use anyhow::Context;
use std::collections::HashMap;
use std::path::Path;
use std::sync::{LazyLock, RwLock};
const PROMPTS_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/src/prompts");
static PROMPT_CACHE: LazyLock<RwLock<HashMap<&'static str, &'static str>>> =
LazyLock::new(|| RwLock::new(HashMap::default()));
let filesystem_path = Path::new(PROMPTS_DIR).join(name);
if let Some(cached_contents) = PROMPT_CACHE.read().unwrap().get(name) {
return Cow::Borrowed(cached_contents);
}
let contents = std::fs::read_to_string(&filesystem_path)
.context(name)
.expect("Failed to read prompt");
let leaked = contents.leak();
PROMPT_CACHE.write().unwrap().insert(name, leaked);
return Cow::Borrowed(leaked);
}
#[cfg(not(feature = "dynamic_prompts"))]
pub fn get_prompt(name: &'static str) -> Cow<'static, str> {
use rust_embed::RustEmbed;
#[derive(RustEmbed)]
#[folder = "src/prompts"]
struct EmbeddedPrompts;
match EmbeddedPrompts::get(name) {
Some(file) => match file.data {
Cow::Borrowed(bytes) => {
Cow::Borrowed(std::str::from_utf8(bytes).expect("prompt file is not valid UTF-8"))
}View on GitHub (pinned to f4178619ac)
Solutions
- Return Cow<'static, str> from a fallible loader or cache the error and report which prompt file is missing instead of panicking
- Fall back to the rust_embed-compiled copy of the prompt when the filesystem read fails
- Run tests/builds with the same prompt asset set and validate all prompt names exist at startup
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/edit_prediction_cli/src/prompt_assets.rs:21 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/5ad902d6cc83b026.
Report an issue: GitHub.