tonhowtf/omniget · error

kdeconnect-cli falhou

Error message

kdeconnect-cli falhou: {}

What it means

After run() successfully locates and spawns kdeconnect-cli with the given args, it checks the child process exit status. A non-zero exit makes the library surface kdeconnect-cli's stderr (trimmed) as an anyhow error, so the underlying CLI failure message is preserved for the caller.

Solutions

  1. Read the stderr text embedded in the error message — it is the CLI's own diagnostic; fix the condition it reports.
  2. Run `kdeconnect-cli --list-devices` manually to confirm a paired, reachable device exists, and pair with `kdeconnect-cli --pair -d <id>` if needed.
  3. Ensure the KDE Connect daemon is running (`kdeconnectd` or restart the KDE Connect app) and the phone/desktop app is open and on the same network.
  4. Retry the operation once the device is available; the error is deterministic for the current device state, not transient.

Example fix

// before
kdeconnect.share_file("nonexistent-device", "/tmp/x.pdf").await?;
// kdeconnect-cli falhou: No such device or device not paired

// after
let devices = kdeconnect.refresh().await?; // pick a valid paired id
kdeconnect.share_file(&devices[0].id, "/tmp/x.pdf").await?;
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure a device is paired and reachable first
let out = Command::new("kdeconnect-cli").args(["--list-devices"]).output()?;
if String::from_utf8_lossy(&out.stdout).trim().is_empty() {
    eprintln!("no paired KDE Connect device");
}

Try / catch

match kdeconnect.share_text(device, msg).await {
    Err(e) if e.to_string().starts_with("kdeconnect-cli falhou") => {
        log::warn!("kdeconnect-cli stderr: {}", e);
        prompt_user_to_pair_device();
    }
    r => r?,
}

Prevention

When it happens

Trigger: Any share_file/share_url/share_text/ping/refresh call where the spawned kdeconnect-cli invocation exits non-zero — e.g. no paired device, device offline, wrong device id passed through args, or the KDE Connect daemon not running.

Common situations: No devices paired (`kdeconnect-cli --list-devices` empty); remote device unreachable or screen locked; kdeconnectd not running; specifying a device name/id that does not exist; permissions missing to send files to the device.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/91a6c2c1aca6c609. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/kdeconnect.rs:103

        .unwrap_or_default();
    KdeStatus {
        installed: true,
        path: Some(bin.to_string_lossy().to_string()),
        devices,
        install_hint: hint,
    }
}

async fn run(args: &[&str]) -> anyhow::Result<String> {
    let bin = locate()
        .await
        .ok_or_else(|| anyhow!("kdeconnect-cli nao encontrado"))?;
    let out = crate::core::process::command(&bin)
        .args(args)
        .output()
        .await?;
    if !out.status.success() {
        return Err(anyhow!(
            "kdeconnect-cli falhou: {}",
            String::from_utf8_lossy(&out.stderr).trim()
        ));
    }
    Ok(String::from_utf8_lossy(&out.stdout).trim().to_string())
}

pub async fn share_file(device: &str, path: &str) -> anyhow::Result<String> {
    run(&["-d", device, "--share", path]).await
}

pub async fn share_url(device: &str, url: &str) -> anyhow::Result<String> {
    run(&["-d", device, "--share", url]).await
}

pub async fn share_text(device: &str, text: &str) -> anyhow::Result<String> {
    run(&["-d", device, "--share-text", text]).await
}

View on GitHub (pinned to 8600b91f42)