{"record":{"id":"7592a6a50fed54ea","repo":"denisidoro/navi","slug":"name-not-set","errorCode":null,"errorMessage":"{name} not set","messagePattern":"(.+?) not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/env_var.rs","lineNumber":34,"sourceCode":"pub const FZF_OVERRIDES_VAR: &str = \"NAVI_FZF_OVERRIDES_VAR\";\npub const FINDER: &str = \"NAVI_FINDER\";\n\npub const CONFIG: &str = \"NAVI_CONFIG\";\npub const CONFIG_YAML: &str = \"NAVI_CONFIG_YAML\";\n\npub fn parse<T: FromStr>(varname: &str) -> Option<T> {\n    if let Ok(x) = env::var(varname) {\n        x.parse::<T>().ok()\n    } else {\n        None\n    }\n}\n\npub fn must_get(name: &str) -> String {\n    if let Ok(v) = env::var(name) {\n        v\n    } else {\n        panic!(\"{name} not set\")\n    }\n}\n\npub fn escape(name: &str) -> String {\n    name.replace('-', \"_\")\n}\n","sourceCodeStart":16,"sourceCodeEnd":41,"githubUrl":"https://github.com/denisidoro/navi/blob/f7330b9ad5bd95b7d1a3c96d00e0a77deb589147/src/env_var.rs#L16-L41","documentation":"`env_var::must_get(name)` reads an environment variable and panics with \"{name} not set\" if it is missing. It is used for variables navi considers mandatory (e.g. config/feature selectors), so absence is treated as a fatal configuration error rather than a recoverable one.","triggerScenarios":"Calling `must_get(\"SOME_VAR\")` (directly or via navi internals) when `std::env::var(name)` returns Err — i.e. the variable is absent from the process environment (empty-string values are OK and returned).","commonSituations":"Running navi without exporting a required variable, typos in variable names (e.g. NAVI_PATH vs NAVI_PATHS), CI environments that don't inherit your shell exports, or running under systemd/cron where the interactive shell profile isn't loaded.","solutions":["Export the required variable before running: `export NAVI_VAR=value`","Set it inline for one run: `NAVI_VAR=value navi ...`","Check for name mismatches — navi accepts dash or underscore in some lookups via `env_var::escape`, but the raw name must match exactly for must_get","Add the export to your shell profile (~/.bashrc, ~/.zshrc) so it persists"],"exampleFix":"// before (fails)\n$ navi some-subcommand\n// thread 'main' panicked at 'NAVI_PATH not set'\n// after\n$ export NAVI_PATH=\"$HOME/.navi\"\n$ navi some-subcommand","handlingStrategy":"validation","validationCode":"fn require_env(name: &str) -> std::io::Result<String> {\n    std::env::var(name).map_err(|_| {\n        std::io::Error::new(std::io::ErrorKind::NotFound, format!(\"{} not set\", name))\n    })\n}\n// call sites: require_env(\"NAVI_PATH\")? before spawning navi","typeGuard":"fn env_set(name: &str) -> Option<String> {\n    std::env::var(name).ok().filter(|v| !v.is_empty())\n}","tryCatchPattern":"// must_get panics; use catch_unwind or check first\nif std::env::var_os(name).is_some() {\n    let v = navi::env_var::must_get(name);\n} else {\n    eprintln!(\"{} not set\", name);\n    std::process::exit(1);\n}","preventionTips":["Export required variables in shell profiles and CI setup steps","Double-check exact variable names (watch dash vs underscore)","Set variables inline when running one-off commands","Avoid relying on interactive-only exports in cron/systemd contexts"],"tags":["environment","env-var","panic","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"f7330b9ad5bd95b7d1a3c96d00e0a77deb589147","analyzedAt":"2026-09-03T13:58:22.429Z","contentChangedAt":"2026-09-03T13:58:22.429Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}