elkowar/eww · error

Error, missing argument

Error message

Error, missing argument '{}' when creating window with id '{}'

What it means

WindowArguments::get_local_window_variables checks that every non-optional argument declared in the window definition (expected_args) is present among the provided local variables/args. If a required argument is missing when creating a window instance, eww bails with this error naming the argument and window id.

Solutions

  1. Supply the missing argument: `eww open <window> <arg>=<value>`
  2. Mark the argument optional in the window definition if it is not truly required
  3. Use `eww windows` to inspect the window's expected args and what you passed
  4. Update scripts/autostart configs that open the window to pass all required args

Example fix

// before
eww open bar
// after
eww open bar idx=0 monitor=1
Defensive patterns

Strategy: validation

Validate before calling

const required = windowDef.expectedArgs.filter(a => !a.optional);
const missing = required.filter(a => !(a.name in providedArgs));
if (missing.length) throw new Error(`missing: ${missing.map(a => a.name).join(', ')}`);

Type guard

function hasRequiredArgs(def, args) { return def.expectedArgs.every(a => a.optional || a.name in args); }

Try / catch

try { execSync(`eww open ${win} ${args}`); } catch (e) { if (String(e).includes("missing argument")) { console.error('Supply all required window args, e.g. eww open bar idx=0'); } else { throw e; } }

Prevention

When it happens

Trigger: Running `eww open <window>` where the window's (defwindow ... expected-args) declares a required attribute that was not supplied — e.g. `eww open bar foo=1` omitting a required arg like `:expected-args "{idx}"` with no idx given.

Common situations: Windows defined with :expected-args but opened without `eww open window key=value`; widget repetition helpers (windows opened per monitor/workspace) missing the monitor/workspace argument; renamed arguments not updated in the open command.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of elkowar/eww@48f5aa8b37 (2026-09-08). Data as JSON: /api/errors/7dad8939a649f97b. Report an issue: GitHub.

Appendix: source

Thrown at crates/eww/src/window_arguments.rs:75

        let expected_args: HashSet<&String> = window_def.expected_args.iter().map(|x| &x.name.0).collect();
        let mut local_variables: HashMap<VarName, DynVal> = HashMap::new();

        // Ensure that the arguments passed to the window that are already interpreted by eww (id, screen)
        // are set to the correct values
        if expected_args.contains(&String::from("id")) {
            local_variables.insert(VarName::from("id"), DynVal::from(self.instance_id.clone()));
        }
        if self.monitor.is_some() && expected_args.contains(&String::from("screen")) {
            let mon_dyn = DynVal::from(&self.monitor.clone().unwrap());
            local_variables.insert(VarName::from("screen"), mon_dyn);
        }

        local_variables.extend(self.args.clone());

        for attr in &window_def.expected_args {
            let name = VarName::from(attr.name.clone());
            if !local_variables.contains_key(&name) && !attr.optional {
                bail!("Error, missing argument '{}' when creating window with id '{}'", attr.name, self.instance_id);
            }
        }

        if local_variables.len() != window_def.expected_args.len() {
            let unexpected_vars: Vec<_> = local_variables.keys().filter(|&n| !expected_args.contains(&n.0)).cloned().collect();
            bail!(
                "variables {} unexpectedly defined when creating window with id '{}'",
                unexpected_vars.join(", "),
                self.instance_id,
            );
        }

        Ok(local_variables)
    }
}

View on GitHub (pinned to 48f5aa8b37)