Hmbown/CodeWhale · error

reviewed plugin stage could not be opened for launch

Error message

reviewed plugin stage could not be opened for launch

What it means

Before launching a reviewed plugin's stdio MCP server, prepare_stdio_launch re-validates the staged manifest from disk with PluginManifest::validate_from_path. If the staged file cannot be read/parsed/validated at all, the launch is refused with this opaque error; the underlying cause is deliberately collapsed so unvalidated content never reaches launch. A companion check (hash comparison) catches the file having merely changed.

Solutions

  1. Re-stage the plugin: rerun the review/install flow so the manifest is written and validated before launch.
  2. Check the staged manifest path exists and is readable (ls/stat the staged_manifest path).
  3. Look for processes (cleaners, tmpreaper, concurrent plugin updates) deleting the staging directory.
  4. Log the inner validate_from_path error in a dev build to pinpoint whether it's I/O or schema failure.

Example fix

// before
let launch = prepare.launch_stdio(&plugin).await?;
// after
if !std::path::Path::new(&stage.staged_manifest).exists() {
    stage = plugin_registry.restage(&plugin.id).await?; // re-review + re-stage
}
let launch = prepare.launch_stdio(&plugin).await?;
Defensive patterns

Strategy: validation

Validate before calling

// verify the staged manifest is present and parses before requesting launch
let path = &stage.staged_manifest;
if !path.exists() { stage = registry.restage(&plugin.id).await?; }
let _ = crate::plugins::manifest::PluginManifest::validate_from_path(path)?;

Type guard

fn stage_launchable(stage: &StagedPlugin) -> bool {
    stage.staged_manifest.exists()
        && PluginManifest::validate_from_path(&stage.staged_manifest).is_ok()
}

Try / catch

match prepare.launch_stdio(&plugin).await {
    Err(e) if e.to_string().contains("could not be opened for launch") => {
        let fresh = registry.restage(&plugin.id).await?; // re-review + re-stage
        prepare.launch_stdio_from(&fresh).await
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling prepare_stdio_launch when the staged manifest file is missing, deleted between review and launch, unreadable (permissions), or corrupt/unparseable so validate_from_path returns Err.

Common situations: A temp/staging directory cleaned up by the OS or another process between plugin review and launch, race with a plugin update replacing the stage, filesystem permission changes, or a partially written manifest.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/c5a42e37c415259b. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/mcp.rs:680

    }

    pub(crate) fn prepare_stdio_launch(
        &self,
        server_name: &str,
        command: &str,
        args: &[String],
        cwd: Option<&Path>,
    ) -> Result<ReviewedStdioLaunch> {
        self.validate_before_stdio_spawn(server_name)?;
        let staged_root = self
            .authority
            .staged_manifest
            .parent()
            .context("reviewed plugin stage manifest has no parent")?;
        let validated = crate::plugins::manifest::PluginManifest::validate_from_path(
            &self.authority.staged_manifest,
        )
        .map_err(|_| anyhow::anyhow!("reviewed plugin stage could not be opened for launch"))?;
        if validated.content_hash != self.authority.content_hash
            || validated.capability_hash != self.authority.capability_hash
        {
            anyhow::bail!("reviewed plugin stage changed before stdio launch");
        }

        let mut launch = ReviewedStdioLaunch {
            command: std::ffi::OsString::from(command),
            args: args.iter().map(std::ffi::OsString::from).collect(),
            cwd: cwd.map(Path::to_path_buf),
            opened_files: Vec::new(),
            #[cfg(unix)]
            cwd_fd: None,
        };
        if Path::new(command).is_absolute() {
            launch.bind_command(staged_root, Path::new(command), &validated.file_hashes)?;
        }
        // Darwin descriptor paths lose Node's module filename, package.json

View on GitHub (pinned to 73e0f67d83)