os-sdlc gate subprocess inherits the plugin's bundler env, so project tests cannot load their own gems #536

Closed
opened 2026-09-08 18:35:57 +00:00 by jared · 1 comment
Owner

Discovered in project hyperthrive-websites, ticket #37, in a git worktree at .claude/worktrees/ticket-37.

lib/os_sdlc/boot.rb (ADR-0166) sets ENV["BUNDLE_GEMFILE"] to the plugin's Gemfile and calls require "bundler/setup". Bundler exports BUNDLE_GEMFILE and RUBYOPT=-rbundler/setup into the process env.

lib/os_sdlc/runner/gate_evaluator.rb:22 runs the gate with Open3.capture3(command), which inherits that env. lib/os_sdlc/runner/gate_commands.rb:36 builds the diff-test step as plain ruby -I<test_path> -e ....

Result: the child ruby loads the plugin's gem set, not the project's. Observed error, identical across dispatches 7, 8, 9: cannot load such file -- webmock/minitest (LoadError) from migrator/test/test_helper.rb:6. The same command run by hand from the project dir passes: 19 runs, 43 assertions, 0 failures. The full project suite passes: 401 runs, 0 failures.

Consequence: the pipeline looped programmer-repair three times on a non-defect. The test-writer's gate accepted the LoadError as "red for the right reason", so the problem surfaced only at the programmer node. The operator had to abandon the pipeline and finish the ticket by hand.

Suggested fix (for the maintainer to judge): wrap the gate spawn in Bundler.with_unbundled_env { ... } and pass chdir: project_root; or build the command as bundle exec ruby ... when the project has a Gemfile. Also consider having the test-writer gate reject a LoadError as "red for the wrong reason".


Discoverer: hyperthrive-websites, session 74ec3fb6-e8b1-4a36-8f40-cd104339836b, 2026-09-08. os-sdlc pipeline loops on bundler env isolation issue

Discovered in project hyperthrive-websites, ticket #37, in a git worktree at .claude/worktrees/ticket-37. `lib/os_sdlc/boot.rb` (ADR-0166) sets `ENV["BUNDLE_GEMFILE"]` to the plugin's Gemfile and calls `require "bundler/setup"`. Bundler exports `BUNDLE_GEMFILE` and `RUBYOPT=-rbundler/setup` into the process env. `lib/os_sdlc/runner/gate_evaluator.rb:22` runs the gate with `Open3.capture3(command)`, which inherits that env. `lib/os_sdlc/runner/gate_commands.rb:36` builds the diff-test step as plain `ruby -I<test_path> -e ...`. Result: the child ruby loads the plugin's gem set, not the project's. Observed error, identical across dispatches 7, 8, 9: `cannot load such file -- webmock/minitest (LoadError)` from `migrator/test/test_helper.rb:6`. The same command run by hand from the project dir passes: `19 runs, 43 assertions, 0 failures`. The full project suite passes: `401 runs, 0 failures`. Consequence: the pipeline looped programmer-repair three times on a non-defect. The test-writer's gate accepted the LoadError as "red for the right reason", so the problem surfaced only at the programmer node. The operator had to abandon the pipeline and finish the ticket by hand. Suggested fix (for the maintainer to judge): wrap the gate spawn in `Bundler.with_unbundled_env { ... }` and pass `chdir: project_root`; or build the command as `bundle exec ruby ...` when the project has a Gemfile. Also consider having the test-writer gate reject a LoadError as "red for the wrong reason". -------- **Discoverer:** hyperthrive-websites, session 74ec3fb6-e8b1-4a36-8f40-cd104339836b, 2026-09-08. os-sdlc pipeline loops on bundler env isolation issue
Author
Owner

Resolution

Done: already fixed: ProjectShell spawns project commands with Bundler.unbundled_env and unsetenv_others

Evidence: #594 / ADR-0191 mechanism, refined by ADR-0205; plugins/os-sdlc/lib/os_sdlc/adapter/project_shell.rb:13; loop script confirmed RUBYOPT and BUNDLE_GEMFILE are nil in the child

Follow-ups: none

## Resolution **Done:** already fixed: ProjectShell spawns project commands with Bundler.unbundled_env and unsetenv_others **Evidence:** #594 / ADR-0191 mechanism, refined by ADR-0205; plugins/os-sdlc/lib/os_sdlc/adapter/project_shell.rb:13; loop script confirmed RUBYOPT and BUNDLE_GEMFILE are nil in the child **Follow-ups:** none
jared closed this issue 2026-09-28 16:46:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#536
No description provided.