docmirror/dev-sidecar · warning
macOS 代理服务检测:未通过服务列表找到可用网络服务
Error message
macOS 代理服务检测:未通过服务列表找到可用网络服务
What it means
Non-fatal warning from the fallback stage of getMacNetworkService(). Both primary strategies failed, so the code listed all services via `networksetup -listallnetworkservices` and ran pickMacNetworkService(), which returned null (empty or unusable list). This warning is logged just before the function throws the fatal Error '未找到可用的 macOS 网络服务,无法设置系统代理'.
Source
Thrown at packages/core/src/shell/scripts/set-system-proxy/index.js:272
log.warn('macOS 代理服务检测:未通过设备名匹配到网络服务,尝试备用方法')
} catch (e) {
log.warn('macOS 代理服务检测:获取网络服务列表失败:', e.message, ',尝试备用方法')
}
} else {
log.warn('macOS 代理服务检测:未检测到当前网络设备,尝试备用方法')
}
} catch (e) {
log.warn('macOS 代理服务检测:获取路由信息失败:', e.message, ',尝试备用方法')
}
try {
const allServicesOutput = await exec('networksetup -listallnetworkservices')
const fallbackService = pickMacNetworkService(allServicesOutput)
if (fallbackService) {
log.info('macOS 代理服务检测:通过服务列表备用方法找到网络服务:', fallbackService)
return fallbackService
}
log.warn('macOS 代理服务检测:未通过服务列表找到可用网络服务')
} catch (e) {
log.warn('macOS 代理服务检测:获取所有网络服务列表失败:', e.message)
}
throw new Error('未找到可用的 macOS 网络服务,无法设置系统代理')
}
// macOS exit code 14 = "You don't have permission to change the system preferences."
const MACOS_NETWORKSETUP_PERMISSION_ERROR_CODE = 14
/**
* POSIX single-quote escaping: wraps `arg` in single quotes, escaping any
* embedded single quotes with the '\''-idiom. This prevents shell
* metacharacter expansion regardless of the character set of the value.
* @param {string|number} arg
* @returns {string}
*/
function shellEscapeArg (arg) {View on GitHub (pinned to 7710cd56cc)
Solutions
- Recreate a network service in System Settings > Network (add Wi-Fi or Ethernet service) so networksetup can report at least one service
- Verify with `networksetup -listallnetworkservices` that at least one real service name is printed; if not, repair network configuration or reset NVRAM/network settings
- If automatic proxy setup cannot work, set the macOS proxy manually (System Settings > Network > Proxies) or skip the proxy.enable option in DevSidecar config
Defensive patterns
Strategy: validation
Validate before calling
const { execSync } = require('node:child_process')
function hasNetworkServices() {
try {
const out = execSync('networksetup -listallnetworkservices').toString()
const services = out.split(/\r?\n/).map(s => s.replace(/^\*/, '').trim())
.filter(s => s && !s.startsWith('An asterisk'))
return services.length > 0
} catch { return false }
}
if (!hasNetworkServices()) throw new Error('No macOS network services configured; create one in System Settings') Type guard
function extractServices(output) {
if (typeof output !== 'string') return []
return output.split(/\r?\n/).map(s => s.replace(/^\*/, '').trim())
.filter(s => s && !s.startsWith('An asterisk (*) denotes'))
} Try / catch
try {
await DevSidecar.api.config.set('proxy.enable', true)
} catch (e) {
if (e.message.includes('未找到可用的 macOS 网络服务')) {
// guide user to recreate a network service or set proxy manually
}
} Prevention
- Never delete all services in System Settings > Network
- On VM/headless macOS images, provision at least one network service
- Verify `networksetup -listallnetworkservices` lists a real service before enabling automation
When it happens
Trigger: `networksetup -listallnetworkservices` returns output containing only the asterisk legend line ('An asterisk (*) denotes...') and no service names, or an empty string — i.e. the system reports no network services at all.
Common situations: Macs with all network services deleted in System Settings > Network; corrupted network configuration; headless/virtualized macOS images with no configured interfaces.
Related errors
- macOS 代理服务检测:获取所有网络服务列表失败:
- macOS 代理服务检测:未通过设备名匹配到网络服务,尝试备用方法
- macOS 代理服务检测:获取网络服务列表失败:
- networksetup 命令需要管理员权限(exit code 14),正在弹出系统授权对话框...
- 未找到可用的 macOS 网络服务,无法设置系统代理
AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31).
Data as JSON: /api/errors/9c74bb385285b98c.
Report an issue: GitHub.