fix(ruby): apply launchConfig.env to the debuggee spawn env (#318) - #321
Merged
Conversation
rdbg -c starts the debuggee at adapter-spawn time, so env sent in the later DAP launch request is a dead letter — ruby was the only adapter where dapLaunchArgs.env silently did nothing. Merge launchConfig.env into the spawn env in buildAdapterCommand, user values last so an explicit value wins over inherited process.env and adapter defaults. Covered by unit tests pinning the merge order and a hard e2e test that launches with dapLaunchArgs.env and reads ENV[] via evaluate_expression at a breakpoint (was "nil" before the fix). Sibling gap for cwd filed as #320. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #318.
Problem
envpassed viadapLaunchArgswas silently dropped on the ruby launch path. It survivestransformLaunchConfiginto the DAPlaunchrequest, but withrdbg --open -c -- ruby <script>the debuggee is already running when that request arrives — the launch response is effectively an ack. Ruby is the only adapter with this gap: python/js/go/rust/dotnet/java all apply user env when the debug adapter launches the debuggee at DAP-launch time (verified per adapter).Everything upstream and downstream was already correct —
dapLaunchArgs.envlands atAdapterConfig.launchConfig.envwith no shadowed-key warning (envis deliberately listed as a legitimate DAP launch key inserver.ts), and the spawn plumbing passesAdapterCommand.envverbatim. The single break wasbuildAdapterCommandnever reading it.Fix
Merge
launchConfig.envinto the spawn env, user values last:An explicit user value wins over both inherited
process.envand adapter defaults (a user settingRUBY_DEBUG_DAP_SHOW_PROTOCOLexplicitly presumably intends it). Env inherits throughbundle execautomatically; no interaction with the #317-rprelude (argv vs env). Attach mode untouched — the target process is already running (documented).Tests
mcp-server-smoke-ruby.test.ts): launch fizzbuzz withdapLaunchArgs: { env: { MCP_TEST_ENV_318: 'hello-318' } }, evaluateENV['MCP_TEST_ENV_318']at a breakpoint. Red against the pre-fix build ("nil"), green after.command.env, overrides an inheritedprocess.envkey, and overrides the adapter default; no-env case pins today's behavior. Addedvi.unstubAllEnvs()to the suite'safterEachsince env stubbing is now in play.docs/ruby/README.mdnew "Environment variables" section).Sibling gap filed as #320:
launchConfig.cwdis dead on the ruby launch path the same way (AdapterCommandhas no cwd channel; spawn layer already supports it).🤖 Generated with Claude Code