codex exec hangs under systemd --user on WSL2, but works in normal shell

Open 💬 1 comment Opened Mar 26, 2026 by xiangmy21

Summary

On my machine, codex exec works normally in an interactive shell and in a regular shell background process, but hangs when launched from a systemd --user unit or via systemd-run --user.

This was discovered while using cc-connect as a Weixin bridge, but I reproduced the core problem with systemd-run --user directly.

Environment

  • OS: Ubuntu 24.04.3 LTS
  • Runtime: WSL2
  • Codex CLI: 0.116.0
  • Login status: Logged in using ChatGPT

Reproduction

This works in a normal shell:

codex exec --skip-git-repo-check --full-auto --json --cd /home/xiangmy21/hw-project1 "测试"

This also works in a normal shell even with stdin redirected from /dev/null:

codex exec --skip-git-repo-check --full-auto --json --cd /home/xiangmy21/hw-project1 "测试" </dev/null

But this hangs under systemd --user:

systemd-run --user --wait --pipe \
  -p WorkingDirectory=/home/xiangmy21/hw-project1 \
  -E HOME=/home/xiangmy21 \
  -E USER=xiangmy21 \
  -E LOGNAME=xiangmy21 \
  -E XDG_RUNTIME_DIR=/run/user/1000 \
  -E XDG_CONFIG_HOME=/home/xiangmy21/.config \
  -E XDG_DATA_HOME=/home/xiangmy21/.local/share \
  -E PATH=/home/xiangmy21/.nvm/versions/node/v24.14.0/bin:/usr/local/bin:/usr/bin:/bin \
  codex exec --skip-git-repo-check --full-auto --json --cd /home/xiangmy21/hw-project1 "测试"

Observed behavior

  • thread.started is printed
  • turn.started is printed
  • then it hangs indefinitely
  • no final item.completed / turn.completed

I also observed the same behavior when codex exec was launched by cc-connect from a systemd --user service.

Expected behavior

codex exec should either:

  • complete normally under systemd --user, or
  • fail fast with a clear error if that environment is unsupported

Notes

  • The project directory is trusted in ~/.codex/config.toml
  • codex login status reports a valid login
  • The exact same command completes normally outside systemd --user
  • On the same machine, switching from systemd --user to a regular shell background process avoids the issue entirely

If helpful, I can provide more environment details, but the systemd-run --user command above is the smallest reproduction I found.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗