{"record":{"id":"6effcb170f4be3fb","repo":"docmirror/dev-sidecar","slug":"macos-6effcb","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":259,"sourceCode":"async function getMacNetworkService (exec) {\n  try {\n    const routeOutput = await exec('route -n get 0.0.0.0')\n    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 网络服务，无法设置系统代理')","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/core/src/shell/scripts/set-system-proxy/index.js#L241-L277","documentation":"Non-fatal warning from getMacNetworkService(). The primary strategy requires the active network device name parsed from `route -n get 0.0.0.0` (an `interface: enX` line). When the route command succeeded but no interface line could be parsed — parseMacRouteDevice returned null — this warning is logged and the fallback service-list strategy is used instead.","triggerScenarios":"`route -n get 0.0.0.0` returns output without an `interface:` line (no default route, unusual locale/format), or returns empty/unexpected output while the machine has no active IPv4 default route.","commonSituations":"Machine with no active network connection when the proxy is toggled on; only an IPv6 route present; heavily localized/modified routing table output; running inside a sandbox where the routing table is inaccessible.","solutions":["No action required — the fallback `networksetup -listallnetworkservices` path runs automatically and typically picks Wi-Fi or Ethernet","Ensure the Mac has an active network connection (Wi-Fi/Ethernet with a default route) before enabling the system proxy; test with `route -n get 0.0.0.0 | grep interface`","If you rely on a VPN/tunnel as your only route, manually configure the proxy or ensure the underlying physical interface is up"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const { execSync } = require('node:child_process')\nfunction hasDefaultRoute() {\n  try {\n    const out = execSync('route -n get 0.0.0.0').toString()\n    return /interface:\\s*\\S+/.test(out)\n  } catch { return false }\n}\nif (!hasDefaultRoute()) console.warn('No default route; automatic service detection will use fallback')","typeGuard":"function parseInterface(routeOutput) {\n  if (typeof routeOutput !== 'string') return null\n  const m = routeOutput.split(/\\r?\\n/).find(l => l.trim().startsWith('interface:'))\n  return m ? m.slice('interface:'.length).trim() || null : null\n}","tryCatchPattern":"if (!hasDefaultRoute()) {\n  // pre-check before enabling system proxy; fall back to manual proxy settings\n  return\n}\nawait DevSidecar.api.config.set('proxy.enable', true)","preventionTips":["Enable the proxy only while the Mac has an active IPv4 default route","Avoid relying on a VPN tunnel (utun) as the sole interface for auto-detection","Run `route -n get 0.0.0.0` after network changes to confirm connectivity"],"tags":["macos","routing","default-route","fallback"],"backgroundTag":"no-default-route","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}