docmirror/dev-sidecar · warning

gsettings 关闭系统代理失败(可能无桌面环境)

Error message

gsettings 关闭系统代理失败(可能无桌面环境)

What it means

Non-fatal warning in the Linux system-proxy setter when disabling the proxy. After (optionally) removing the proxy environment variables from the shell profile, the code runs `gsettings set org.gnome.system.proxy mode none` to clear the GNOME desktop proxy. If that command fails, this warning is logged and the operation continues without throwing — meaning the GNOME desktop proxy may remain set to manual even though the env vars were removed.

Source

Thrown at packages/core/src/shell/scripts/set-system-proxy/index.js:618

      // 设置排除域名(ignore-hosts)
      const excludeIpStr = getProxyExcludeIpStr('\', \'')
      setProxyCmd.push(`gsettings set org.gnome.system.proxy ignore-hosts "['${excludeIpStr}']"`)

      try {
        await exec(setProxyCmd)
      } catch (e) {
        log.warn('gsettings 设置系统代理失败(可能无桌面环境),环境变量已设置')
      }
    } else { // 关闭代理
      if (setEnv) {
        removeProxyEnvFromShellProfile()
      }

      try {
        await exec(['gsettings set org.gnome.system.proxy mode none'])
      } catch (e) {
        log.warn('gsettings 关闭系统代理失败(可能无桌面环境)')
      }
    }
  },
  async mac (exec, params = {}) {
    const wifiAdaptor = await getMacNetworkService(exec)
    const { ip, port, setEnv } = params

    let cmds
    if (ip != null) { // 设置代理
      // 延迟加载config
      loadConfig()

      // https
      cmds = [`networksetup -setsecurewebproxy "${wifiAdaptor}" ${ip} ${port}`]
      // http
      if (config.get().proxy.proxyHttp) {
        cmds.push(`networksetup -setwebproxy "${wifiAdaptor}" ${ip} ${port - 1}`)
      } else {

View on GitHub (pinned to 7710cd56cc)

Solutions

  1. If headless, ignore — nothing GNOME-side was ever set; confirm env vars were removed from your shell profile and run `source ~/.bashrc` (or `unset HTTPS_PROXY HTTP_PROXY`)
  2. If a desktop proxy was actually set earlier, run `gsettings set org.gnome.system.proxy mode none` inside the desktop session (with D-Bus available) to clear it
  3. Check that GNOME still has a stale manual proxy via `gsettings get org.gnome.system.proxy mode` and clear host/port keys manually if needed
Defensive patterns

Strategy: fallback

Validate before calling

const { execSync } = require('node:child_process')
function gnomeProxyIsManual() {
  try {
    return execSync('gsettings get org.gnome.system.proxy mode').toString().trim() === "'manual'"
  } catch { return false }
}
// if true after turning proxy off, GNOME proxy needs manual cleanup in a desktop session

Try / catch

// Library swallows the failure; verify cleanup yourself:
try {
  if (gnomeProxyIsManual()) {
    execSync('gsettings set org.gnome.system.proxy mode none')
  }
} catch (e) {
  console.warn('Run this inside a desktop session with D-Bus:', e.message)
}

Prevention

When it happens

Trigger: executor.linux() with ip == null (proxy off): no gsettings binary, no D-Bus/desktop session (SSH, service, headless), dconf write failure, or schema not installed.

Common situations: Headless servers where GNOME proxy was never set (harmless); turning the proxy off from an SSH session after enabling it in the desktop; minimal DEs without gsettings.

Related errors


AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31). Data as JSON: /api/errors/d1c7c1bd35f1ad01. Report an issue: GitHub.