Not loading env vars from config.toml

Resolved 💬 6 comments Opened Mar 4, 2026 by heliole Closed Mar 5, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of the IDE extension are you using?

0.4.79

What subscription do you have?

Pro

Which IDE are you using?

VS Code

What platform is your computer?

Darwin 24.6.0 arm64 arm

What issue are you seeing?

When i define .codex/config.toml like this:

[shell_environment_policy]
inherit = "all"
ignore_default_excludes = true
include_only = ["GH_TOKEN"]

it has no effect. Codex extension session has no access to the defined GH_TOKEN env var.

What steps can reproduce the bug?

Define that config file and .env file and see.

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

6 Comments

etraut-openai contributor · 4 months ago

Codex doesn't read .env files. You need to define and export shell environment variables if you want Codex to include them in the sandboxed shell environment.

heliole · 4 months ago

I understand but AFAIK that's not practical if you're using codex thru the IDE extension.
Is there a more practical way to do this other than the manual code . launch every time?
I know defining env vars works in other similar extensions.

heliole · 4 months ago

Actually, can't get it to work even if i launch with code . from a terminal session with this env var defined

etraut-openai contributor · 4 months ago

I confirmed that this works.

Open terminal and type:

export GH_TOKEN="Hello"
code .

Then wait for VS Code to launch and the Codex extension to load.

<img width="378" height="348" alt="Image" src="https://github.com/user-attachments/assets/196ab61b-2bd8-47f8-a0f8-86aeded93421" />

vico93 · 4 months ago

I'm having same issues here (trying to set up github sse on a specifcic workspace). How is the procedure to set such variables on Codex GUI on Windows?

heliole · 4 months ago

@vico93 code . method works, you just have to instruct codex to run gh commands elevated out of the sandbox