[PR #1850] [MERGED] fix: preserve process.env when spawning formatter commands #10088

Closed
opened 2026-02-16 18:14:41 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1850
Author: @CamdenClark
Created: 8/12/2025
Status: Merged
Merged: 8/12/2025
Merged by: @thdxr

Base: devHead: fix/formatter-env-variables


📝 Commits (1)

  • ef74857 fix: preserve process.env when spawning formatter commands

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 packages/opencode/src/format/index.ts (+1 -1)

📄 Description

Fixes issue where custom formatter environment variables would overwrite all process.env variables, causing commands to fail when they need access to system environment variables like PATH.

The formatter now merges process.env with custom environment variables, ensuring system variables are preserved while still allowing custom overrides.

Repro case in opencode.json:

"custom-markdown-formatter": {
  "command": ["deno", "fmt", "$FILE"],
  "environment": {
    "NODE_ENV": "development"
  },
  "extensions": [".md"]
}

🤖 Generated with opencode


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1850 **Author:** [@CamdenClark](https://github.com/CamdenClark) **Created:** 8/12/2025 **Status:** ✅ Merged **Merged:** 8/12/2025 **Merged by:** [@thdxr](https://github.com/thdxr) **Base:** `dev` ← **Head:** `fix/formatter-env-variables` --- ### 📝 Commits (1) - [`ef74857`](https://github.com/anomalyco/opencode/commit/ef748573d9ae3d9c9b150f6ebbc7f6fd4833e580) fix: preserve process.env when spawning formatter commands ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/format/index.ts` (+1 -1) </details> ### 📄 Description Fixes issue where custom formatter environment variables would overwrite all process.env variables, causing commands to fail when they need access to system environment variables like PATH. The formatter now merges process.env with custom environment variables, ensuring system variables are preserved while still allowing custom overrides. Repro case in opencode.json: ```json "custom-markdown-formatter": { "command": ["deno", "fmt", "$FILE"], "environment": { "NODE_ENV": "development" }, "extensions": [".md"] } ``` 🤖 Generated with [opencode](https://opencode.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:41 -05:00
yindo closed this issue 2026-02-16 18:14:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10088