jdx/mise · error
cannot remove user service '{name}': {}
Error message
cannot remove user service '{name}': {} What it means
Removing a user service requires a supported service manager on the platform (systemd on Linux, launchd on macOS). If `is_available()` reports the manager is unavailable, `remove_named` fails with the reason from `unavailable_reason()`.
Source
Thrown at src/system/user_services.rs:659
return Ok(());
}
if cfg!(target_os = "linux") {
systemd::apply(&[request.systemd_request()?], dry_run).await
} else if cfg!(target_os = "macos") {
launchd::apply(&[request.launchd_request()?], dry_run).await
} else {
scheduled_tasks::apply(&[request.scheduled_task_request()], dry_run).await
}
}
/// Remove the installed definition for `name`, declared or not. Returns
/// whether one existed.
pub(crate) async fn remove_named(name: &str, dry_run: bool) -> Result<bool> {
if !valid_name(name) {
bail!("user service name '{name}' must contain only letters, numbers, '.', '_', or '-'");
}
if !is_available() {
bail!(
"cannot remove user service '{name}': {}",
unavailable_reason()
);
}
if cfg!(target_os = "linux") {
systemd::remove_service(name, dry_run).await
} else if cfg!(target_os = "macos") {
launchd::remove_agent(name, dry_run).await
} else {
scheduled_tasks::remove_task(name, dry_run).await
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::system::services_common::ServiceScope;
View on GitHub (pinned to afd2eddd3a)
Solutions
- Run on a system with systemd (Linux) or launchd (macOS) available
- Ensure a user session/systemd user instance is running (`systemctl --user status` works)
- Skip or gate user services in containers/CI config
- Read `unavailable_reason()` in the message for the specific cause
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// Precheck (Linux): systemctl --user works? // systemctl --user status >/dev/null 2>&1 || echo "systemd user session unavailable"
Try / catch
match result {
Err(e) if e.to_string().starts_with("cannot remove user service") => {
// log unavailable_reason() and skip user-service management on this host
}
other => other?,
} Prevention
- Gate user-service config behind host capability detection (systemd/launchd present)
- Skip service management in containers and CI without a user session
- Read the unavailable_reason() text in the error to diagnose the environment
When it happens
Trigger: `remove_named` called (via `apply_one`) on a system where the expected user-service manager is missing/unusable, e.g. Linux without systemd (containers, WSL1, non-systemd distros) or macOS where launchd access fails (src/system/user_services.rs:659).
Common situations: Running bootstrap service management inside Docker containers without systemd; minimal/CI environments without a user session bus (`systemctl --user` unavailable); non-systemd init distros.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- user service '{name}' cannot be masked; use `state = "absent
- user service '{}' is also declared in [bootstrap.linux.syste
- user service '{}' is also declared in [bootstrap.macos.launc
- executable identity contains an unsupported environment vari
- only available on unix
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/d860825524e587e5.
Report an issue: GitHub.