docmirror/dev-sidecar · warning

gsettings 设置系统代理失败(可能无桌面环境),环境变量已设置

Error message

gsettings 设置系统代理失败(可能无桌面环境),环境变量已设置

What it means

Non-fatal warning in the Linux system-proxy setter. Environment variables (HTTP_PROXY/HTTPS_PROXY via proxy.env + shell profile) are always set first; then the code applies the GNOME desktop proxy with a batch of `gsettings set org.gnome.system.proxy ...` commands. If that exec fails, this warning notes that the desktop-level proxy could not be applied (most commonly because there is no GNOME/desktop session or dconf available) but the environment-variable proxy is still in effect, so the function does not throw.

Source

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

        `gsettings set org.gnome.system.proxy.https port ${port}`,
      ]
      // http
      if (config.get().proxy.proxyHttp) {
        setProxyCmd.push(`gsettings set org.gnome.system.proxy.http host ${ip}`)
        setProxyCmd.push(`gsettings set org.gnome.system.proxy.http port ${port - 1}`)
      } else {
        setProxyCmd.push('gsettings set org.gnome.system.proxy.http host \'\'')
        setProxyCmd.push('gsettings set org.gnome.system.proxy.http port 0')
      }

      // 设置排除域名(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

View on GitHub (pinned to 7710cd56cc)

Solutions

  1. If running headless intentionally, ignore this warning — CLI/terminal tools still get the proxy through HTTP(S)_PROXY environment variables (source the printed shell profile)
  2. To make gsettings work, launch DevSidecar inside a desktop session with D-Bus (check `echo $DBUS_SESSION_BUS_ADDRESS` and `which gsettings`)
  3. Verify manually with `gsettings set org.gnome.system.proxy mode manual` in the same session; if that fails, install dconf/gsettings (e.g. `apt install gsettings-desktop-schemas dconf-cli`)
  4. For non-GNOME desktops (KDE, i3), set the desktop proxy via the DE's own settings; DevSidecar only automates GNOME
Defensive patterns

Strategy: fallback

Validate before calling

const { execSync } = require('node:child_process')
function gsettingsAvailable() {
  try {
    execSync('gsettings get org.gnome.system.proxy mode', { stdio: 'ignore' })
    return Boolean(process.env.DBUS_SESSION_BUS_ADDRESS)
  } catch { return false }
}
// false => headless/SSH; env-var proxy only, this warning is expected

Try / catch

// The library does not throw here; treat the log line as informational.
// If you surface warnings, filter this one for headless deployments:
if (!process.env.DBUS_SESSION_BUS_ADDRESS) {
  console.info('Headless environment: relying on HTTP(S)_PROXY env vars only')
}

Prevention

When it happens

Trigger: executor.linux() with ip != null: `gsettings` binary absent, no D-Bus session (running via SSH, systemd service, cron, or headless server), dconf backend unavailable, or GSETTINGS_SCHEMA_DIR/dconf permission problems.

Common situations: SSH or headless Linux boxes where users expect only terminal proxy (env vars) — this warning is expected and harmless; WSL without GUI; minimal window managers (i3/sway) without gnome-settings-daemon; containers.

Related errors


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