xai-org/grok-build · error

Failed to enable plugin: {e}

Error message

Failed to enable plugin: {e}

What it means

cmd_enable enables a plugin by first removing it from the disabled list (failures there are only warned about) and then calling xai_grok_shell::config::add_enabled_plugin. If adding to the enabled list fails, the underlying error is wrapped as "Failed to enable plugin: {e}". The library throws it to surface config-persistence problems to the plugin enable command's caller.

Source

Thrown at crates/codegen/xai-grok-pager/src/plugin_cmd.rs:614

            }
        }
    }
    Ok(())
}

fn cmd_enable(name: &str) -> Result<()> {
    let registry = InstallRegistry::load();
    if registry.find_plugin(name).is_none() {
        bail!(
            "Plugin \"{name}\" not found.\n\
               Run `grok plugin list` to see installed plugins."
        );
    }
    if let Err(e) = xai_grok_shell::config::remove_disabled_plugin(name) {
        tracing::warn!("failed to remove from disabled list: {e}");
    }
    xai_grok_shell::config::add_enabled_plugin(name)
        .map_err(|e| anyhow::anyhow!("Failed to enable plugin: {e}"))?;
    println!("Enabled plugin: {name}");
    Ok(())
}

fn cmd_disable(name: &str) -> Result<()> {
    let registry = InstallRegistry::load();
    if registry.find_plugin(name).is_none() {
        bail!(
            "Plugin \"{name}\" not found.\n\
               Run `grok plugin list` to see installed plugins."
        );
    }
    if let Err(e) = xai_grok_shell::config::remove_enabled_plugin(name) {
        tracing::warn!("failed to remove from enabled list: {e}");
    }
    xai_grok_shell::config::add_disabled_plugin(name)
        .map_err(|e| anyhow::anyhow!("Failed to disable plugin: {e}"))?;
    println!("Disabled plugin: {name}");

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Read the underlying {e} after the prefix — it names the config file/IO or parse problem.
  2. Fix permissions on the config file/directory (chown/chmod) or run as the owning user.
  3. If the config file is corrupted, back it up and repair or regenerate the JSON.
  4. Ensure the config directory exists and the filesystem is writable (disk space, mount ro/rw).
Defensive patterns

Strategy: try-catch

Validate before calling

fn config_writable() -> bool {
    xai_grok_shell::config::config_path()
        .and_then(|p| p.parent().map(|d| d.exists()))
        .unwrap_or(false)
}
// additionally attempt a no-op write or check metadata permissions before enabling

Try / catch

match xai_grok_shell::config::add_enabled_plugin(name) {
    Ok(()) => println!("enabled {name}"),
    Err(e) => {
        eprintln!("Failed to enable plugin {name}: {e}");
        eprintln!("check config file permissions and JSON validity");
    }
}

Prevention

When it happens

Trigger: Any Err from add_enabled_plugin(name): typically failure to read or write the config file where enabled plugins are recorded (permission denied, missing directory, corrupted/unparseable config, disk full).

Common situations: Config file owned by root or another user after running with sudo; HOME/XDG config dir not writable in containers or CI; config JSON hand-edited into invalid state so load-then-save fails; read-only mounted home directory.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/5c6e4db38c601e5a. Report an issue: GitHub.