Skip to content

fix: inherit process.env when spawning agent subprocess#374

Merged
benbrandt merged 3 commits intozed-industries:mainfrom
joseotaviorf:fix/env-inheritance-external-editor
Mar 4, 2026
Merged

fix: inherit process.env when spawning agent subprocess#374
benbrandt merged 3 commits intozed-industries:mainfrom
joseotaviorf:fix/env-inheritance-external-editor

Conversation

@joseotaviorf
Copy link
Contributor

@joseotaviorf joseotaviorf commented Mar 4, 2026

In 0.20.0, the env option was introduced with an explicit object spread, but without including process.env. This caused the subprocess to receive an empty environment, stripping HOME, PATH and other inherited variables when spawned from an external editor such as Zed.

Add ...process.env as the base so user-provided and gateway env vars still override it, while preserving the parent process environment.

Add tests to verify HOME/PATH are inherited and that user-provided vars are merged on top correctly.

Fixes #373
Closes zed-industries/zed#50664

In 0.20.0, the env option was introduced with an explicit object spread,
but without including process.env. This caused the subprocess to receive
an empty environment, stripping HOME, PATH and other inherited variables
when spawned from an external editor such as Zed.

Add ...process.env as the base so user-provided and gateway env vars
still override it, while preserving the parent process environment.

Add tests to verify HOME/PATH are inherited and that user-provided vars
are merged on top correctly.
@cla-bot
Copy link

cla-bot bot commented Mar 4, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @joseotaviorf on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@joseotaviorf
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Mar 4, 2026
@cla-bot
Copy link

cla-bot bot commented Mar 4, 2026

The cla-bot has been summoned, and re-checked this pull request!

Copy link
Member

@benbrandt benbrandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I missed this in my testing yesterday

@benbrandt benbrandt merged commit 52d5b74 into zed-industries:main Mar 4, 2026
2 checks passed
@benbrandt benbrandt linked an issue Mar 4, 2026 that may be closed by this pull request
@joseotaviorf joseotaviorf deleted the fix/env-inheritance-external-editor branch March 4, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants