[PR #9347] fix: expose autoloadBunfig setting as define for subprocess isolation #13081

Open
opened 2026-02-16 18:17:57 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9347

State: open
Merged: No


Summary

  • Add OPENCODE_AUTOLOAD_BUNFIG define that exposes the compile-time autoloadBunfig setting to runtime code
  • Extract autoloadBunfig to a variable so both compile option and define stay in sync

This enables subprocess spawning logic to apply equivalent bunfig isolation when spawning Bun processes with BUN_BE_BUN=1.

Test plan

  • Build the binary and verify OPENCODE_AUTOLOAD_BUNFIG is defined
  • Verify runtime code can access the define value

Fixes #5349

Root cause analysis (by claude code)

autoloadBunfig: false in the compile options only affects the initial startup of the compiled binary itself. It's baked into the binary at build time.          
                                                                                                                                                                                 
  The problem is:                                                                                                                                                                
                                                                                                                                                                                 
  1. Compiled binary starts → autoloadBunfig: false is respected → no bunfig.toml loaded ✓                                                                                       
  2. Binary spawns subprocess with BUN_BE_BUN=1 → subprocess runs as "raw Bun" → the compile option doesn't carry over → bunfig.toml gets loaded ✗                               
                                                                                                                                                                                 
  The autoloadBunfig setting isn't inherited by child processes. When BUN_BE_BUN=1 is set, the subprocess essentially becomes a fresh Bun runtime that doesn't know about the    
  parent's compile settings.                                                                                                                                                     
                                                                                                                                                                                 
  That's why we need --config=/dev/null as a runtime workaround for subprocesses. The OPENCODE_AUTOLOAD_BUNFIG define just lets the runtime code know what the compile setting   
  was, so it can apply the equivalent protection to subprocesses.                                                                                                                
                                                                                                                                                                                 
  Compiled binary (autoloadBunfig: false)                                                                                                                                        
      │                                                                                                                                                                          
      └─► Subprocess (BUN_BE_BUN=1)                                                                                                                                              
              │                                                                                                                                                                  
              └─► Needs --config=/dev/null to match parent's behavior    

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9347 **State:** open **Merged:** No --- ## Summary - Add `OPENCODE_AUTOLOAD_BUNFIG` define that exposes the compile-time `autoloadBunfig` setting to runtime code - Extract `autoloadBunfig` to a variable so both compile option and define stay in sync This enables subprocess spawning logic to apply equivalent bunfig isolation when spawning Bun processes with `BUN_BE_BUN=1`. ## Test plan - [ ] Build the binary and verify `OPENCODE_AUTOLOAD_BUNFIG` is defined - [ ] Verify runtime code can access the define value Fixes #5349 ## Root cause analysis (by claude code) ``` autoloadBunfig: false in the compile options only affects the initial startup of the compiled binary itself. It's baked into the binary at build time. The problem is: 1. Compiled binary starts → autoloadBunfig: false is respected → no bunfig.toml loaded ✓ 2. Binary spawns subprocess with BUN_BE_BUN=1 → subprocess runs as "raw Bun" → the compile option doesn't carry over → bunfig.toml gets loaded ✗ The autoloadBunfig setting isn't inherited by child processes. When BUN_BE_BUN=1 is set, the subprocess essentially becomes a fresh Bun runtime that doesn't know about the parent's compile settings. That's why we need --config=/dev/null as a runtime workaround for subprocesses. The OPENCODE_AUTOLOAD_BUNFIG define just lets the runtime code know what the compile setting was, so it can apply the equivalent protection to subprocesses. Compiled binary (autoloadBunfig: false) │ └─► Subprocess (BUN_BE_BUN=1) │ └─► Needs --config=/dev/null to match parent's behavior ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-16 18:17:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13081