{"record":{"id":"d5eec833d73159dd","repo":"Unitech/pm2","slug":"init-system-not-found","errorCode":null,"errorMessage":"Init system not found","messagePattern":"Init system not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/API/Startup.js","lineNumber":90,"sourceCode":"    var commands;\n    var that = this;\n    var actual_platform = detectInitSystem();\n    var user = opts.user || process.env.USER || process.env.LOGNAME; // Use LOGNAME on Solaris-like systems\n    var service_name = (opts.serviceName || 'pm2-' + user);\n    var openrc_service_name = 'pm2';\n    var launchd_service_name = (opts.serviceName || 'pm2.' + user);\n\n    if (!platform)\n      platform = actual_platform;\n    else if (actual_platform && actual_platform !== platform) {\n      Common.printOut('-----------------------------------------------------------')\n      Common.printOut(' PM2 detected ' + actual_platform + ' but you precised ' + platform)\n      Common.printOut(' Please verify that your choice is indeed your init system')\n      Common.printOut(' If you arent sure, just run : pm2 startup')\n      Common.printOut('-----------------------------------------------------------')\n    }\n    if (platform === null)\n      throw new Error('Init system not found')\n\n    if (!cb) {\n      cb = function(err, data) {\n        if (err)\n          return that.exitCli(cst.ERROR_EXIT);\n        return that.exitCli(cst.SUCCESS_EXIT);\n      }\n    }\n\n    if (process.getuid() != 0) {\n      return isNotRoot('unsetup', platform, opts, cb);\n    }\n\n    if (fs.existsSync('/etc/init.d/pm2-init.sh')) {\n      platform = 'oldsystem';\n    }\n\n    switch(platform) {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/Unitech/pm2/blob/31adee8048dbbc1ee36a7df7cdbcaca2559708df/lib/API/Startup.js#L72-L108","documentation":"Thrown by CLI.uninstallStartup (pm2 unstartup / pm2 startup --remove). PM2 tries to auto-detect the init system by probing PATH for known tools (systemctl, update-rc.d, chkconfig, rc-update, launchctl, sysrc, rcctl, svcadm) via detectInitSystem(). If none are found and the caller passed no explicit platform, platform stays null and the command aborts.","triggerScenarios":"Running `pm2 unstartup` (or uninstallStartup programmatically) on a host where none of the init tools are on PATH and no platform argument is supplied.","commonSituations":"Minimal containers (e.g. Alpine without openrc-utils installed), exotic/older OSes, WSL environments, CI runners without init tooling.","solutions":["Pass the platform explicitly: `pm2 unstartup systemd` (or upstart, launchd, systemv, openrc, rcd, rcd-openbsd, smf).","Install the init tooling for your distribution so detection succeeds.","Run the command on a real host where the init tool is present."],"exampleFix":"// before\npm2 unstartup\n// after\npm2 unstartup systemd","handlingStrategy":"validation","validationCode":"const which = require('which');\nconst tools = ['systemctl','update-rc.d','chkconfig','rc-update','launchctl','sysrc','rcctl','svcadm'];\nconst detected = tools.find((t) => which(t, { nothrow: true }));\nif (!detected && !process.env.PM2_STARTUP_PLATFORM) {\n  throw new Error('No init system detected; pass an explicit platform (e.g. systemd)');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In containers, always pass the platform explicitly to unstartup/startup.","Confirm the init tool exists in PATH before calling startup programmatically."],"tags":["startup","init-system","platform-detection"],"backgroundTag":null,"analyzedSha":"31adee8048dbbc1ee36a7df7cdbcaca2559708df","analyzedAt":"2026-08-13T03:49:51.765Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}