{"record":{"id":"838f0cd3d9eb0098","repo":"docmirror/dev-sidecar","slug":"macos-838f0c","errorCode":null,"errorMessage":"macOS 代理服务检测：获取所有网络服务列表失败:","messagePattern":"macOS 代理服务检测：获取所有网络服务列表失败:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/src/shell/scripts/set-system-proxy/index.js","lineNumber":274,"sourceCode":"        log.warn('macOS 代理服务检测：获取网络服务列表失败:', e.message, '，尝试备用方法')\n      }\n    } else {\n      log.warn('macOS 代理服务检测：未检测到当前网络设备，尝试备用方法')\n    }\n  } catch (e) {\n    log.warn('macOS 代理服务检测：获取路由信息失败:', e.message, '，尝试备用方法')\n  }\n\n  try {\n    const allServicesOutput = await exec('networksetup -listallnetworkservices')\n    const fallbackService = pickMacNetworkService(allServicesOutput)\n    if (fallbackService) {\n      log.info('macOS 代理服务检测：通过服务列表备用方法找到网络服务:', fallbackService)\n      return fallbackService\n    }\n    log.warn('macOS 代理服务检测：未通过服务列表找到可用网络服务')\n  } catch (e) {\n    log.warn('macOS 代理服务检测：获取所有网络服务列表失败:', e.message)\n  }\n\n  throw new Error('未找到可用的 macOS 网络服务，无法设置系统代理')\n}\n\n// macOS exit code 14 = \"You don't have permission to change the system preferences.\"\nconst MACOS_NETWORKSETUP_PERMISSION_ERROR_CODE = 14\n\n/**\n * POSIX single-quote escaping: wraps `arg` in single quotes, escaping any\n * embedded single quotes with the '\\''-idiom.  This prevents shell\n * metacharacter expansion regardless of the character set of the value.\n * @param {string|number} arg\n * @returns {string}\n */\nfunction shellEscapeArg (arg) {\n  return \"'\" + String(arg).replace(/'/g, \"'\\\\''\") + \"'\"\n}","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/core/src/shell/scripts/set-system-proxy/index.js#L256-L292","documentation":"Non-fatal warning from getMacNetworkService(). The last-resort command `networksetup -listallnetworkservices` itself threw, so no fallback service could be selected. Immediately after this warning the function throws the fatal Error '未找到可用的 macOS 网络服务，无法设置系统代理', which propagates to executor.mac() and fails the set-system-proxy operation.","triggerScenarios":"networksetup cannot be spawned (missing from PATH, exec failure) or exits non-zero when listing services — e.g. sandbox restrictions, damaged network preferences, or the process lacking a proper user session/audit context.","commonSituations":"App launched from a stripped environment (launchd job, IDE debugger with minimal PATH); enterprise-managed Macs where networksetup is restricted; corrupted /Library/Preferences/SystemConfiguration contents.","solutions":["Fix the root cause shown in the logged e.message, then retry enabling the proxy in DevSidecar","Run `networksetup -listallnetworkservices` manually in Terminal to confirm it works for your user; if it errors there, repair macOS network settings (delete and recreate services, or consult IT for managed restrictions)","Set the system proxy manually via System Settings and disable automatic proxy configuration (proxy.enable=false) in DevSidecar config"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const { execSync } = require('node:child_process')\nfunction canListServices() {\n  try { execSync('networksetup -listallnetworkservices', { stdio: 'ignore' }); return true }\n  catch (e) { console.warn('networksetup unusable:', e.message); return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await DevSidecar.api.startup()\n} catch (e) {\n  if (e.message.includes('未找到可用的 macOS 网络服务')) {\n    console.error('Automatic macOS proxy setup impossible; set proxy in System Settings manually')\n  }\n}","preventionTips":["Confirm networksetup works in the exact environment the app runs in (Terminal vs launchd)","Repair corrupted network preferences via System Settings or by recreating services","On MDM-managed Macs, verify networksetup is not restricted by policy"],"tags":["macos","networksetup","exec-failure","fatal-followup"],"backgroundTag":"command-exec-failed","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}