question: codex-cli doesn't see (or inherit) the current environment

Resolved 💬 5 comments Opened Nov 5, 2025 by vigo Closed Jan 10, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

maybe i'm missing something. on my current shell session, virtualenv (from pyenv) is active, python packages are installed, database, redis etc all ok. when i call "codex" i see:

Ran python - <<'PY'
  │ from django.contrib.messages.storage.fallback import FallbackStorage
  │ import inspect
  │ … +2 lines
  └ /opt/homebrew/Library/Homebrew/cmd/shellenv.sh: line 18: /bin/ps: Operation not permitted
    /Users/vigo/Repos/Dropbox/Files/shell-2022/fzf-custom-comprun.bash: line 26:
    _fzf_setup_completion: command not found
    … +2 lines
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'django'

i normally use codex web and i have a setup script to required things to develop. as far as i understand, on my local machine, codex starts kind of clean-slate (i don't know maybe non-interactive shell) and can not run tests etc...

i see:

Tests not run (local environment lacks Django). Suggested next step: install backend
requirements and run.....

any tips? config options? help help :))))

View original on GitHub ↗

5 Comments

github-actions[bot] contributor · 9 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #6243
  • #6218
  • #5837
  • #4843
  • #4620

Powered by Codex Action

baoqiwork · 9 months ago

我也出现了这样的问题,请问您是否解决
Ran python - <<'PY'
│ import pathlib, re, json
│ mapper_dir = pathlib.Path('hosp-edu-service-school-base/src/main/java/com/hxq/edu/service/school/base/mapper')
│ … +58 lines
└ /opt/homebrew/Library/Homebrew/cmd/shellenv.sh: line 18: /bin/ps: Operation not permitted
Mappers: 98
… +63 lines
EncyclopediaResourceRefDao missing 9
EncyclopediaViewRefDao missing 6

kevinthmm · 9 months ago

@vigo @baoqiwork
hi there guys, I was facing a similar issue a couple of days ago, and my issue was that codex always calls python which is a symlink to system's python binary (which do not have your project module installed).

I resolved it by creating an AGENTS.md file in the project root, and instructing codex to always use the virual env python binary

`## When running python

  • do NOT run python or python3
  • always run .venv/bin/python instead.`

sometimes codex forgets and I will have to remind it inside the prompts, but it has mostly resolved my issue. not sure if you guys are facing similar issues, but if so, do give it a shot.

etraut-openai contributor · 7 months ago

We've improved our documentation about shell environment policy since this bug was filed.

zbynekwinkler · 7 months ago
We've improved our documentation about shell environment policy since this bug was filed.

If you could improve it further to show how to inherit PATH variable into the shell_command from the parent process that launched codex, that would be really helpful.