nikivdev/code · error
Refusing to disable Apple service '{}'. This could break you
Error message
Refusing to disable Apple service '{}'. This could break your system. What it means
run_disable blocks disabling services in the Apple category as a safety guard, since disabling OS-provided launchd services can break macOS. The service id must exist (otherwise a separate 'Service not found' error fires); this error fires only for known Apple-owned services.
Source
Thrown at src/macos.rs:301
// Show plist content
println!("\nPlist contents:");
if let Ok(content) = std::fs::read_to_string(&svc.plist_path) {
println!("{}", content);
}
Ok(())
}
fn run_disable(opts: MacosDisableOpts) -> Result<()> {
let services = discover_services()?;
let svc = services
.iter()
.find(|s| s.id == opts.service)
.ok_or_else(|| anyhow::anyhow!("Service '{}' not found", opts.service))?;
if svc.category == ServiceCategory::Apple {
bail!(
"Refusing to disable Apple service '{}'. This could break your system.",
svc.id
);
}
if !opts.yes {
print!("Disable service '{}'? [y/N] ", svc.id);
io::stdout().flush()?;
let mut input = String::new();
io::stdin().read_line(&mut input)?;
if !input.trim().eq_ignore_ascii_case("y") {
println!("Cancelled.");
return Ok(());
}
}
disable_service(svc)?;View on GitHub (pinned to a747e741ae)
Solutions
- Choose a non-Apple service to disable — Apple services are intentionally protected.
- If you truly must change an Apple service, use launchctl directly at your own risk (`sudo launchctl bootout system/<service>`) rather than this tool.
- Re-check the service id; you may have mistyped and matched an Apple service unintentionally.
Example fix
// before flow macos disable com.apple.mDNSResponder // after flow macos disable com.example.my-daemon
Defensive patterns
Strategy: validation
Validate before calling
// check category before invoking disable
let svc = list_services()?.into_iter().find(|s| s.id == "com.apple.mDNSResponder");
if let Some(s) = svc {
if s.category == "apple" {
eprintln!("refusing to disable Apple service");
return;
}
} Type guard
fn is_disallowable(svc: &Service) -> bool {
svc.category == ServiceCategory::Apple
} Try / catch
match macos::run_disable(opts) {
Err(e) if e.to_string().contains("Refusing to disable Apple service") => {
eprintln!("Apple services are protected; use launchctl manually if you accept the risk");
}
other => other?,
} Prevention
- Filter service lists to exclude Apple-category services before scripting disables.
- Double-check the service id — a typo may resolve to an Apple service.
- Treat Apple system services as read-only in automation.
When it happens
Trigger: Running the disable command for a service whose entry has category == ServiceCategory::Apple (e.g. system daemons like com.apple.* services), without any override.
Common situations: Trying to disable Spotlight, mDNSResponder or other Apple system agents to 'free resources'; accidentally passing an Apple service id in a cleanup script.
Related errors
- Failed to disable service: {}
- Failed to enable service: {}
- Failed to bootstrap service: {}
- launchctl bootstrap failed: {}
- launchctl kickstart failed: {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/fa9dae45005ee23f.
Report an issue: GitHub.