glzr-io/glazewm · error

Shell exec failed for

Error message

Shell exec failed for '{command}': command doesn't have an ending `"`.

What it means

`parse_command` in shell_exec splits a shell command into a program name and arguments. When the command string starts with a double quote, the program path is expected to be wrapped in quotes (e.g. `"C:\\path\\to\\app.exe" --flag`); if no second closing quote exists, `match_indices('"').nth(2)` returns `None` and this error is raised with the original command echoed back.

Solutions

  1. Add the missing closing quote around the program path: `"C:\\path\\to\\app.exe" --flag`.
  2. If the path has no spaces, drop the quotes entirely so the quoted-path branch is skipped.
  3. Inspect the `command` value echoed in the error and fix the quoting in the config source (e.g. `general.yml` startup or keybinding command).
  4. Escape quotes correctly for your config format if the shell command itself contains quotes.
  5. Validate the command string in an editor/shell before putting it into the config.

Example fix

// before (config)
command: '"C:\\Program Files\\app.exe --flag'
// after
command: '"C:\\Program Files\\app.exe" --flag'
Defensive patterns

Strategy: validation

Validate before calling

fn shell_exec_command_is_quoted(cmd: &str) -> bool {
  if cmd.starts_with('"') { cmd[1..].contains('"') } else { true }
}

Try / catch

let (program, args) = parse_command(&cmd).map_err(|e| {
  eprintln!("Fix quoting in shell command: {e}");
  e
})?;

Prevention

When it happens

Trigger: Calling `shell_exec` with a command like `"C:\\Program Files\\app.exe --flag` — starts with `"` but has no matching closing quote before the arguments.

Common situations: Config files where a quoted path lost its closing quote (manual edit, escaping issues in TOML/JSON, line truncation); commands copied from Windows with smart quotes or partial quoting.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of glzr-io/glazewm@5709ad0a3c (2026-09-08). Data as JSON: /api/errors/0ddca358d7348cc5. Report an issue: GitHub.

Appendix: source

Thrown at packages/wm/src/commands/general/shell_exec.rs:120

      state.dispatcher.expand_env_strings(command)?
    }
    #[cfg(target_os = "macos")]
    {
      // TODO: Expand env variables on macOS.
      command.to_string()
    }
  };

  let command_parts =
    expanded_command.split_whitespace().collect::<Vec<_>>();

  // If the command starts with double quotes, then the program name/path
  // is wrapped in double quotes (e.g. `"C:\path\to\app.exe" --flag`).
  if expanded_command.starts_with('"') {
    // Find the closing double quote.
    let (closing_index, _) =
      expanded_command.match_indices('"').nth(2).ok_or_else(|| {
        anyhow::anyhow!(
          "Shell exec failed for '{command}': command doesn't have an ending `\"`."
        )
      })?;

    return Ok((
      expanded_command[1..closing_index].to_string(),
      expanded_command[closing_index + 1..].trim().to_string(),
    ));
  }

  // The first part is the program name if it doesn't contain a slash or
  // backslash.
  if let Some(first_part) = command_parts.first() {
    if !first_part.contains(&['/', '\\'][..]) {
      let args = command_parts[1..].join(" ");
      return Ok(((*first_part).to_string(), args));
    }
  }

View on GitHub (pinned to 5709ad0a3c)