Skip to content

Implement --eval as alternative to sub-shell mode and envrc - #329

Merged
mclasmeier merged 16 commits into
mainfrom
mc/subshell-spawning
Nov 3, 2026
Merged

mclasmeier merged 16 commits into
mainfrom
mc/subshell-spawning

Conversation

@mclasmeier

@mclasmeier mclasmeier commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add --eval flag to roxie deploy and roxie shell, enabling eval "$(roxie deploy --eval)" / eval "$(roxie shell --eval)" workflows to source ACS environment variables directly into the current shell — no subshell needed, so aliases, functions, and all shell state are preserved.
  • Move all logger output from stdout to stderr unconditionally, following Unix convention (diagnostic output belongs on stderr). This keeps stdout clean for structured output like --eval.
  • Base color detection on stderr's TTY status instead of stdout's, so colors work correctly when stdout is captured by command substitution.
  • Spawn subshell with -l -i instead of just -i, so login profile files (~/.bash_profile, ~/.zprofile) are sourced — picks up aliases defined there.

Motivation

Colleagues reported that shell aliases defined in their local setup were missing in the roxie subshell. The subshell is a new process that can never fully replicate the parent shell's state. --eval sidesteps the problem entirely by staying in the user's existing shell.

Test plan

  • eval "$(roxie deploy --eval)" deploys and exports env vars into current shell
  • eval "$(roxie shell --eval)" re-exports env vars for existing deployment
  • roxctl central whoami works after eval (CA cert file persists)
  • roxie deploy (without --eval) still spawns subshell with banner and colors
  • roxie deploy --eval --envrc foo errors with mutual exclusivity message
  • Colors render correctly in both eval and subshell modes
  • NO_COLOR=1 roxie deploy disables colors

Summary by CodeRabbit

  • New Features
    • Added --eval support to deployment and shell commands to print shell-ready environment exports instead of launching a subshell. Banners are sent to stderr, keeping exports on stdout.
    • Central deployments can run non-interactively with --eval. Shell eval mode can also report detached port forwarding.
  • Bug Fixes
    • Environment values are now quoted for safe shell evaluation.
    • Terminal color output is disabled when color is unsupported or stderr is not a terminal.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The deploy and shell commands add eval mode that prints environment exports instead of starting a subshell. Export values use POSIX shell quoting. Logger output now goes to stderr, and end-to-end tests source envrc files through a shell.

Changes: Eval-mode output

Layer / File(s) Summary
Shell quoting and output support
cmd/main.go, cmd/subshell.go, internal/helpers/helpers.go, internal/deployer/deployer.go, internal/logger/*, tests/e2e/*, go.mod
Environment exports use shell quoting. The banner accepts a writer, logger records go to stderr, and color detection checks stderr. End-to-end tests source envrc files through a shell.
Deployment eval path
cmd/deploy.go
The deploy command adds --eval, sets the environment output destination to /dev/stdout, and prints the Central deployment banner to stderr and exports to stdout. Non-interactive Central deployments accept --eval as an alternative to --envrc.
Shell command eval path
cmd/shell.go
The shell command adds --eval. In eval mode, it retains the temporary directory, starts enabled Central port forwarding in detached mode, prints the banner and exports, then returns without running a command or subshell.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ShellCommand
  participant CentralPortForward
  participant stderr
  participant stdout
  ShellCommand->>CentralPortForward: start forwarding in detached mode
  ShellCommand->>stderr: print deployment banner
  ShellCommand->>stdout: print environment exports and forwarding PID
Loading
Merge Risk: Minimal · up to c4029

The eval workflows preserve the emitted environment and detached port-forward state, with no material merge-blocking risk identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Implement --eval as alternative to sub-shell mode and envrc" matches the main change. The PR adds an --eval flag to deploy and shell that prints environment exports to stdout instead of sta…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Implement --eval as alternative to sub-shell mode and envrc" matches the main change. The PR adds an --eval flag to deploy and shell that prints environment exports to stdout instead of starting a subshell or writing an envrc file. The title is specific, names the flag, and states the alternative it replaces. The changeset also includes logger, color, and helper changes, which the title does not mention, but those are supporting changes and do not need to appear in the title.

Full details: Docstring Coverage

Explanation

Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 12 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between e4c511f and c402976.

Files selected for processing: 1
  • tests/e2e/helpers.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread cmd/deploy.go Resolved
Comment thread cmd/shell.go Resolved
Comment thread cmd/subshell.go Resolved
Comment thread cmd/subshell.go Resolved

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread cmd/shell.go Resolved
Comment thread internal/deployer/deployer.go Resolved
Comment thread cmd/deploy.go Resolved

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread tests/e2e/helpers.go Resolved

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread tests/e2e/helpers.go Resolved
@mclasmeier
mclasmeier requested a review from AlexVulaj November 3, 2026 14:54
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@mclasmeier
mclasmeier merged commit b5aa8ed into main Nov 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants