{"record":{"id":"d860825524e587e5","repo":"jdx/mise","slug":"cannot-remove-user-service-name","errorCode":null,"errorMessage":"cannot remove user service '{name}': {}","messagePattern":"cannot remove user service '(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/user_services.rs","lineNumber":740,"sourceCode":"        // an apply boots the agent out and back in, which restarts it\n        launchd::apply(&[request.launchd_request()?], dry_run).await\n    } else {\n        // Task Scheduler keeps a running instance across an unchanged\n        // registration, so a forced restart has to end and run it\n        let mut task = request.scheduled_task_request();\n        task.restart = restart == Restart::Forced;\n        scheduled_tasks::apply(&[task], dry_run).await\n    }\n}\n\n/// Remove the installed definition for `name`, declared or not. Returns\n/// whether one existed.\npub(crate) async fn remove_named(name: &str, dry_run: bool) -> Result<bool> {\n    if !valid_name(name) {\n        bail!(\"user service name '{name}' must contain only letters, numbers, '.', '_', or '-'\");\n    }\n    if !is_available() {\n        bail!(\n            \"cannot remove user service '{name}': {}\",\n            unavailable_reason()\n        );\n    }\n    if cfg!(target_os = \"linux\") {\n        systemd::remove_service(name, dry_run).await\n    } else if cfg!(target_os = \"macos\") {\n        launchd::remove_agent(name, dry_run).await\n    } else {\n        scheduled_tasks::remove_task(name, dry_run).await\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use crate::system::services_common::ServiceScope;\n","sourceCodeStart":722,"sourceCodeEnd":758,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/user_services.rs#L722-L758","documentation":"After name validation, `remove_named` checks whether a user service manager is available on the current platform (systemd on Linux, launchd on macOS). If `is_available()` returns false, it bails with the manager-specific reason from `unavailable_reason()`, since no removal can be performed.","triggerScenarios":"Calling remove_named on a platform without the expected init system — e.g. systemd missing/not running (containers, WSL1 without systemd, minimal images) — or running a macOS-targeted flow where launchd access fails.","commonSituations":"Running `mise user-service remove` inside a Docker container or CI job with no systemd user session, or on WSL setups where systemd is disabled in /etc/wsl.conf.","solutions":["Enable systemd (e.g. [boot] systemd=true in /etc/wsl.conf on WSL2, then reboot the distro)","Start the systemd user session: `systemctl --user` should work; ensure DBUS_SESSION_BUS_ADDRESS/XDG_RUNTIME_DIR are set","Remove the service definition manually (delete the unit/plist file) if no service manager is available","Run the removal on the platform where the service is actually installed"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# verify a usable user service manager before attempting removal\nsystemctl --user is-system-running 2>/dev/null || echo \"systemd user session unavailable\"","typeGuard":null,"tryCatchPattern":"try {\n  await run(['mise', 'user-service', 'remove', name]);\n} catch (e) {\n  console.warn('service manager unavailable; removing definition file manually');\n  await run(['rm', '-f', `~/.config/systemd/user/${name}.service`]);\n}","preventionTips":["Check `systemctl --user status` (Linux) before scripting service operations","Enable systemd in WSL2 (/etc/wsl.conf [boot] systemd=true) if using WSL","Skip user-service tasks in CI/containers where no init system runs"],"tags":["platform","systemd","user-services","environment"],"backgroundTag":"unsupported-platform","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}