glzr-io/glazewm · error

Shell exec failed for

Error message

Shell exec failed for '{command}'. Make sure the program exists and is accessible from your shell. Error: {err}

What it means

`shell_exec` spawns a shell command via the platform API and wraps any spawn failure with this message naming the command and the underlying OS error. It means the OS could not run the program — typically the executable was not found or is not executable.

Solutions

  1. Verify the program is installed and resolvable from your shell (`which <program>` / `where <program>`)
  2. Use an absolute path to the executable in the config
  3. Inspect the wrapped `err` in the message for the precise OS cause

Example fix

// before
shell_exec("code", vec![], None, false)?;
// after
shell_exec("C:\\Program Files\\Microsoft VS Code\\Code.exe", vec![], None, false)?;
Defensive patterns

Strategy: validation

Validate before calling

fn program_exists(program: &str) -> bool {
  std::process::Command::new("where")
    .arg(program)
    .output()
    .map(|o| o.status.success())
    .unwrap_or(false)
}

Try / catch

match shell_exec(command, args, None, false) {
  Err(e) if e.to_string().contains("Shell exec failed") => {
    eprintln!("check that '{command}' is installed and on PATH");
  }
  r => r?,
}

Prevention

When it happens

Trigger: `shell_exec(executable, args, ...)` where the program path does not exist, lacks the execute bit / PATH resolution fails, or the OS denies spawning.

Common situations: Keybinding configs invoking apps like `"code"` or `"alacritty"` that are not on PATH or not installed, wrong absolute paths, or missing file permissions.

Related errors


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

Appendix: source

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

    {
      let home_dir =
        home::home_dir().context("Unable to get home directory.")?;

      // TODO: Use `Shell::spawn` instead. `ShellExecuteExW` is still used
      // to be able to launch programs from the App Paths registry
      // (`HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths`), like
      // `chrome` without it being in $PATH.
      state.dispatcher.shell_execute_ex(
        &program,
        &args,
        &home_dir,
        hide_window,
      )
    }
  };

  result.map_err(|err| {
    anyhow::anyhow!(
      "Shell exec failed for '{command}'. Make sure the program exists and is \
      accessible from your shell. Error: {err}",
    )
  })?;

  Ok(())
}

/// Parses a command string into a program name/path and arguments. This
/// also expands any environment variables found in the command string if
/// they are wrapped in `%` characters. If the command string is a path,
/// a file extension is required.
///
/// This is similar to the `SHEvaluateSystemCommandTemplate` Win32
/// function. It also parses program name/path and arguments, but can't
/// handle `/` as file path delimiters and it errors for certain programs
/// (e.g. `code`).
///

View on GitHub (pinned to 5709ad0a3c)