nikivdev/code · error

Bike.app failed to open {}

Error message

Bike.app failed to open {}

What it means

Raised by open_bike (src/todo.rs:90) when the `open -a Bike.app <file>` subprocess completes but reports unsuccessful (non-zero exit). Bike.app was found (existence check passed at line 80), but launching it or opening the todo file with it failed.

Source

Thrown at src/todo.rs:90

    };
    if needs_init {
        let content = render_bike_template(&project_name);
        fs::write(&path, content)?;
    }

    let bike_app = Path::new("/System/Volumes/Data/Applications/Bike.app");
    if !bike_app.exists() {
        bail!("Bike.app not found at {}", bike_app.display());
    }

    let status = Command::new("open")
        .arg("-a")
        .arg(bike_app)
        .arg(&path)
        .status()
        .context("failed to launch Bike.app")?;
    if !status.success() {
        bail!("Bike.app failed to open {}", path.display());
    }

    Ok(())
}

fn looks_like_bike(content: &str) -> bool {
    let trimmed = content.trim_start();
    if !trimmed.starts_with("<?xml") {
        return false;
    }
    let lower = trimmed.to_ascii_lowercase();
    lower.contains("<html") && lower.contains("<body") && lower.contains("<ul")
}

fn render_bike_template(project_name: &str) -> String {
    let now = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
    let ul_id = format!("_{}", Uuid::new_v4().simple());
    let li_id = Uuid::new_v4().simple().to_string();

View on GitHub (pinned to a747e741ae)

Solutions

  1. Run `open -a Bike.app <path>` manually to see the actual LaunchServices error message.
  2. Ensure you are in a GUI session (not SSH) or enable remote Apple Events / run inside a logged-in desktop session.
  3. Reinstall or repair Bike.app; clear quarantine with `xattr -dr com.apple.quarantine /path/to/Bike.app`.
  4. Verify the todo file exists and is readable by the current user.

Example fix

// before
bail!("Bike.app failed to open {}", path.display());
// after: capture stderr for diagnosis
let out = Command::new("open").arg("-a").arg(&bike_app).arg(&path).output()?;
if !out.status.success() {
    bail!("Bike.app failed to open {}: {}", path.display(), String::from_utf8_lossy(&out.stderr));
}
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure a GUI session can launch apps before calling
let gui = std::env::var("TERM_PROGRAM").is_ok() || std::env::var("Apple_PubSub_Socket_Render").is_ok();
if !gui { eprintln!("no GUI session; `open -a` will fail"); }

Try / catch

match result {
    Err(e) if e.to_string().contains("Bike.app failed to open") => {
        eprintln!("launch failed; try `open -a Bike.app` manually and check stderr");
    }
    Err(e) => return Err(e),
    Ok(v) => v,
}

Prevention

When it happens

Trigger: The `open` command exits non-zero — e.g. Bike.app is quarantined/damaged, refuses to open the .hoops file, LaunchServices cannot associate the file type, or the system is in a state where GUI apps cannot launch (SSH session, headless CI).

Common situations: Running the todo open command over SSH or from a non-GUI context where `open` cannot launch apps; corrupted or moved Bike.app after the exists() check; file permissions preventing Bike.app from opening the todo path.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/b2fd3d0a289d1f8b. Report an issue: GitHub.