{"record":{"id":"d119d169d5de9d95","repo":"docmirror/dev-sidecar","slug":"macos-d119d1","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":262,"sourceCode":"    const device = parseMacRouteDevice(routeOutput)\n    if (device) {\n      log.info('macOS 代理服务检测：当前网络设备:', device)\n      try {\n        const networkServiceOrder = await exec('networksetup -listnetworkserviceorder')\n        const matchedService = parseMacNetworkServiceByDevice(networkServiceOrder, device)\n        if (matchedService) {\n          log.info('macOS 代理服务检测：通过设备名匹配到网络服务:', matchedService)\n          return matchedService\n        }\n        log.warn('macOS 代理服务检测：未通过设备名匹配到网络服务，尝试备用方法')\n      } catch (e) {\n        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.\"","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/core/src/shell/scripts/set-system-proxy/index.js#L244-L280","documentation":"Non-fatal warning from getMacNetworkService(). The first strategy failed entirely: the outer `exec('route -n get 0.0.0.0')` rejected, so the route/device detection could not run at all. The code logs the underlying e.message and continues to the fallback strategy using `networksetup -listallnetworkservices`.","triggerScenarios":"The `route` binary is missing or not spawnable; `route -n get 0.0.0.0` exits non-zero because there is no route to the default destination (common when offline); exec wrapper treats any non-zero exit as rejection.","commonSituations":"Offline or airplane-mode machines where enabling the proxy is attempted; restricted environments lacking /sbin on PATH; freshly booted machines before the network is up.","solutions":["No action needed — the code automatically falls back to listing all network services and picks Wi-Fi/Ethernet","Check the logged e.message: if it is 'no route to host'/'not in table', connect to a network before enabling the system proxy","If `route` is genuinely missing from PATH, launch the app from a standard shell environment where /usr/sbin is on PATH"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const { execSync } = require('node:child_process')\nfunction routeCommandWorks() {\n  try { execSync('route -n get 0.0.0.0', { stdio: 'ignore' }); return true }\n  catch (e) { console.warn('route check failed:', e.message); return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await DevSidecar.api.startup()\n} catch (e) {\n  if (/route|network/i.test(e.message)) {\n    // network detection failed; prompt user to check connectivity\n  }\n}","preventionTips":["Ensure the machine is online before toggling the system proxy","Launch from a standard shell so /usr/sbin (route) is on PATH","If intentionally offline, disable automatic system-proxy setup in config"],"tags":["macos","routing","route-command","fallback"],"backgroundTag":"no-default-route","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}