{"record":{"id":"82a4dd017bcbf70e","repo":"elkowar/eww","slug":"the-script-for-the-variable-exited-unsuccessf-82a4dd","errorCode":null,"errorMessage":"The script for the `{}`-variable exited unsuccessfully","messagePattern":"The script for the `(.+?)`-variable exited unsuccessfully","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/script_var_handler.rs","lineNumber":202,"sourceCode":"        });\n    }\n\n    fn stop_for_variable(&mut self, name: &VarName) {\n        if let Some(token) = self.poll_handles.remove(name) {\n            log::debug!(\"stopped poll var {}\", name);\n            token.cancel()\n        }\n    }\n\n    fn stop_all(&mut self) {\n        self.poll_handles.drain().for_each(|(_, token)| token.cancel());\n    }\n}\n\npub fn run_poll_once(var: &PollScriptVar) -> Result<DynVal> {\n    match &var.command {\n        VarSource::Shell(span, command) => {\n            script_var::run_command(command).map_err(|e| anyhow!(create_script_var_failed_warn(*span, &var.name, &e.to_string())))\n        }\n        VarSource::Function(x) => x().map_err(|e| anyhow!(e)),\n    }\n}\n\nimpl Drop for PollVarHandler {\n    fn drop(&mut self) {\n        self.stop_all();\n    }\n}\n\nstruct ListenVarHandler {\n    evt_send: UnboundedSender<DaemonCommand>,\n    listen_process_handles: HashMap<VarName, cancellation::AwaitableCancelationSender>,\n}\n\nimpl ListenVarHandler {\n    fn new(evt_send: UnboundedSender<DaemonCommand>) -> Result<Self> {","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/script_var_handler.rs#L184-L220","documentation":"run_poll_once executes a polling script variable's command once and returns its output as a DynVal. For a shell command source, a non-zero exit is converted into this error (with a contextual warning naming the var and command); for a function source, any returned error is propagated.","triggerScenarios":"The poll loop (or an explicit `eww poll` via force_poll_variable) invokes run_poll_once and the var's shell command exits non-zero, or its Rust function source returns Err.","commonSituations":"Script depends on a missing binary; intermittent failures (network check, acpi absent); quoting/whitespace bugs in the command; command returns non-zero on transient conditions.","solutions":["Run the command manually and fix the non-zero exit condition","Make the script resilient: append `|| echo fallback` or handle expected failures inside the script","Suppress stderr / normalize exit codes for commands that legitimately report via exit codes"],"exampleFix":"// before\n(defpoll net :interval \"5s\" \"curl -fsSL https://example.com/health\")  ; fails when offline\n\n// after\n(defpoll net :interval \"5s\" \"curl -fsSL https://example.com/health || echo offline\")","handlingStrategy":"try-catch","validationCode":"# sanity-check the poll command exits 0\nbash -c \"$(grep -oP '(?<=:command \")[^\"]+' ~/.config/eww/eww.yuck)\" || echo fix","typeGuard":null,"tryCatchPattern":"match script_var_handler::run_poll_once(&var) {\n    Ok(v) => update(v),\n    Err(e) => { log::warn!(\"poll failed: {e:#}\"); keep_last_value(); }\n}","preventionTips":["Make poll scripts idempotent and always exit 0 on expected failures","Redirect stderr and emit fallback text","Avoid transient-network commands without `|| echo fallback`"],"tags":["eww","script-var","polling","shell-command"],"backgroundTag":"command-not-found","analyzedSha":"48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa","analyzedAt":"2026-09-08T03:13:26.897Z","contentChangedAt":"2026-09-08T03:13:26.897Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}