elkowar/eww · error
The script for the ` `-variable exited unsuccessfully
Error message
The script for the `{}`-variable exited unsuccessfully What it means
initial_value computes the first value of a script variable. For a `VarSource::Shell` (a shell command from `:command`), the command is run once synchronously; if it exits non-zero, eww wraps the failure warning in this error saying the script for the variable exited unsuccessfully.
Solutions
- Run the :command string manually in a shell and fix whatever makes it exit non-zero
- Make the script exit 0 even on failure (e.g. append `|| echo 'fallback'` or `2>/dev/null || true`)
- Install missing dependencies the script relies on
Example fix
; before
(defpoll cpu :interval "1s" "mpstat 1 1 | awk '/Average/{print $3}'") ; mpstat not installed
; after
(defpoll cpu :interval "1s" "command -v mpstat >/dev/null && mpstat 1 1 | awk '/Average/{print $3}' || echo 0") Defensive patterns
Strategy: try-catch
Validate before calling
// shell: verify the command succeeds before configuring it mycommand || echo "fix: exits $?, would break initial value"
Try / catch
match script_var::initial_value(&var) {
Ok(v) => /* use v */,
Err(e) => log::warn!("using default for {}: {e:#}", var.name()),
} Prevention
- Test every :command manually first
- Always end poll scripts with a guaranteed exit 0 fallback
- Install dependencies before deploying the config
When it happens
Trigger: Defining a polled/initial script var whose `:command` shell string fails on first evaluation — command not found, non-zero exit, bad syntax — when the initial value is computed.
Common situations: Command depends on a tool not installed; script fails on a fresh machine before dependencies exist; quoting errors in the yuck command string; command exits non-zero under eww's environment.
Related errors
- The script for the ` `-variable exited unsuccessfully
- Script var ' ' is not polling
- Failed with output
- CSS error
- Encountered both an SCSS and CSS file. Only one of these…
AI-assisted analysis of elkowar/eww@48f5aa8b37 (2026-09-08).
Data as JSON: /api/errors/fb5563a397aad6eb.
Report an issue: GitHub.
Appendix: source
Thrown at crates/eww/src/config/script_var.rs:31
pub fn create_script_var_failed_warn(span: Span, var_name: &VarName, error_output: &str) -> DiagError {
DiagError(gen_diagnostic! {
kind = Severity::Warning,
msg = format!("The script for the `{}`-variable exited unsuccessfully", var_name),
label = span => "Defined here",
note = error_output,
})
}
pub fn initial_value(var: &ScriptVarDefinition) -> Result<DynVal> {
match var {
ScriptVarDefinition::Poll(x) => match &x.initial_value {
Some(value) => Ok(value.clone()),
None => match &x.command {
VarSource::Function(f) => f()
.map_err(|err| anyhow!(err))
.with_context(|| format!("Failed to compute initial value for {}", &var.name())),
VarSource::Shell(span, command) => {
run_command(command).map_err(|e| anyhow!(create_script_var_failed_warn(*span, var.name(), &e.to_string())))
}
},
},
ScriptVarDefinition::Listen(var) => Ok(var.initial_value.clone()),
}
}
/// Run a command and get the output
pub fn run_command(cmd: &str) -> Result<DynVal> {
log::debug!("Running command: {}", cmd);
let command = Command::new("/bin/sh").arg("-c").arg(cmd).output()?;
if !command.status.success() {
bail!("Failed with output:\n{}", String::from_utf8(command.stderr)?);
}
let output = String::from_utf8(command.stdout)?;
let output = output.trim_matches('\n');
Ok(DynVal::from(output))View on GitHub (pinned to 48f5aa8b37)