Skip to content

Remove the dead --dump-environment-variables flag from bun build - #44370

Merged
Jarred-Sumner merged 2 commits into
mainfrom
robobun/1a0f62a8/remove-dump-environment-variables
Oct 2, 2026
Merged

Jarred-Sumner merged 2 commits into
mainfrom
robobun/1a0f62a8/remove-dump-environment-variables

Conversation

@robobun

@robobun robobun commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Behaviour change: none

One error path differs. See Downsides.

Problem

  • bun build --dump-environment-variables does nothing. BUILD_ONLY_PARAMS declares the flag (src/runtime/cli/Arguments.rs:538), but no code reads it.
  • DebugOptions.dump_environment_variables is always false, so the branch at src/runtime/cli/build_command.rs:604 and Transpiler::dump_environment_variables cannot run.
  • The completions still offer the flag, with --dump-limits and --disable-bun-js, whose fields Narrow crate-internal Rust visibility across all targets and delete the code it proves dead #36184 deleted.

Fix

  • Delete the param, the field, the branch and the function. Remove the three names from the completions.
  • Correct on current main: the parser skips an unknown long flag in silence (src/clap/streaming.rs:157). The bare flag gives the same bundle as before.
  • Verified: bun bd, test/bundler/cli.test.ts, bundler_env.test.ts, test/cli/bun.test.ts, test/cli/run/env.test.ts. No new test: REVIEW.md says "Do not add tests to check dead code stays dead".
  • Self-reviewed: 14 concerns raised, 13 addressed. Rejected: to drop the first line. It stays because the PR adds no test.

Background

Downsides

Notes

Deleted, one line each

  • parse_param!("--dump-environment-variables") in BUILD_ONLY_PARAMS (src/runtime/cli/Arguments.rs).
  • DebugOptions.dump_environment_variables and its default (src/options_types/context.rs).
  • The if ctx.debug.dump_environment_variables { ... } branch in BuildCommand::exec, and the stale comment above it (src/runtime/cli/build_command.rs).
  • Transpiler::dump_environment_variables (src/bundler/transpiler.rs). write_json_string and the iterator of bun_dotenv::Map have other callers.
  • completions/bun.zsh: the --dump-environment-variables and --dump-limits specs in _bun_run_completion.
  • completions/bun.bash: --dump-environment-variables --dump-limits --disable-bun-js in GLOBAL_OPTIONS.

Behaviour, measured

Released bun 1.4.3 against a debug build of this branch. "Same bundle" means the same bytes on stdout as bun build x.js.

Input Before After
bun build --dump-environment-variables x.js exit 0, same bundle exit 0, same bundle
bun build --dump-environment-variables=1 x.js exit 1, "The argument '--dump-environment-variables' does not take a value." exit 0, same bundle
bun build --dump-environment-variables= x.js exit 1, same error exit 0, same bundle
BUN_OPTIONS=--dump-environment-variables=1 bun build x.js exit 1, same error exit 0, same bundle
bun build --no-such-flag=1 x.js exit 0, same bundle exit 0, same bundle

bun build --help never listed the flag. WARN_ON_UNRECOGNIZED_FLAG (src/clap/streaming.rs:10) is never set to true, so the skip prints nothing. This PR does not touch it. #40560 removes it.

History

  • 38f83c50c4 and 5691bf385b (October 2021) added the flag for the old bun bun and bun dev commands.
  • Runs of release binaries with bun build --dump-environment-variables x.js: 0.8.0 prints valid JSON. 1.0.1 and 1.0.11 print one JSON string per fragment ("{", then "\n ", then "PATH",), which is not valid JSON. The cause is 19aa9d93de (update zig to 0.11.0 #4233, first in 0.8.1): Map.jsonStringify changed from writer.writeAll to writer.write on the JSON stream.
  • Up to 1.0.11 the flag was declared one time, with help text, in debug_params, and src/cli.zig:593 read it for every command. CLI flags #6395 deleted that list and added a new declaration, with no help text, to build_only_params only.
  • In the branch of CLI flags #6395, 5bf8ad8fb9 commented out the line that reads the flag, under a source comment that says the two dump flags were "only used in bun dev". fbbb5e7e38 ("Remove comments") deleted the commented lines. The merged commit does not contain that comment. bun build had its own consumer (src/cli/build_command.zig:220), and it stayed.
  • --dump-environment-variables doesn't work, bun run env ignores files #5712 is the only issue that names the flag. It asked for bun run on bun 1.0.2, and it ended with "This flag appears to have been removed".
  • No maintainer has ruled on the flag. Narrow crate-internal Rust visibility across all targets and delete the code it proves dead #36184 deleted DebugOptions.dump_limits and DebugOptions.fallback_only, the fields of the other two debug flags. jsx: remove the dead Solid runtime from bunfig, the CLI, and tsconfig #41699 removed the dead Solid JSX runtime in the same way.

If the flag is wanted back

The one-line reader is not enough. bun build --app returns into bake::production::build_command before the branch. The branch runs after the compile target lookup, so it must move to directly after configure_defines(). --watch needs a decision. The flag needs help text and docs.

Completions: what stays

  • The three names are the completion entries of the three old DebugOptions debug flags. After this PR none of their fields exists.
  • completions/bun.bash GLOBAL_OPTIONS still has nine names that no param table declares: --use --bunfile --server-bunfile --disable-react-fast-refresh --disable-hmr --jsx-production --platform --public-dir --inject. completions: generate fish/bash from bun-cli.json #35443 generates that file from bun-cli.json. completions: optimize parsing, add --cwd support, and fix bash 3.2 compatibility #42275 rewrites the same line.
  • _bun_run_completion in completions/bun.zsh still has eleven specs that bun run does not declare: --no-summary --version -v --revision --external --packages --minify --minify-syntax --minify-whitespace --minify-identifiers --target. Other commands declare them.

DebugOptions fields with no reader that stay

Other params with no reader

207 long flags are declared in Arguments.rs. 13 have no b"--name" reader in src/**/*.rs:

  • --tls-min-v1.0, --tls-min-v1.1, --tls-min-v1.2, --tls-max-v1.3: src/js/node/tls.ts reads them from process.execArgv.
  • --trace-events-enabled and six more --trace-* flags: declared on purpose, see the comment above them.
  • --grep: an alias of --test-name-pattern.
  • --dump-environment-variables: the only one with no reader and no stated reason.

Checks

  • test/bundler/cli.test.ts: 38 pass, 0 fail. test/bundler/bundler_env.test.ts: 7 pass, 0 fail. test/cli/bun.test.ts: 39 pass, 0 fail. test/cli/run/env.test.ts: 107 pass, 0 fail. All with --timeout 120000, because the machine was under heavy load.
  • bash -n completions/bun.bash passes. zsh was not available, so completions/bun.zsh was checked by reading. The new last line of the _arguments call ends with ' &&, like the other calls in the file.
  • The debug binary has no dump-environment-variables string. The completion scripts are embedded with include_bytes!, so bun completions installs the edited scripts.
  • Release binary size in CI against main: no target grows. Four of the twelve targets are 2 to 4 KB smaller (FreeBSD x64 and aarch64, Windows x64 and aarch64).
  • Substitutes, run on bun 1.4.3: bun --print process.env prints the process variables and the .env values. logLevel = "debug" in bunfig.toml makes bun build --env inline print the .env files that it loads.

no test proof · iteration 1 · the description declares no behaviour change, so there is no failing test to prove; the existing suite in CI is the check

`bun build` declares the flag, but no code reads it since bun 1.0.12
(#6395). `DebugOptions.dump_environment_variables` is never set, so the
branch in `BuildCommand::exec` and
`Transpiler::dump_environment_variables` cannot run.

Delete the param, the field, the branch and the function. Remove the
flag from the zsh and bash completions, together with `--dump-limits`
and `--disable-bun-js`. Those are the two other debug flags of the old
`DebugOptions`, and #36184 deleted their fields.
@github-actions github-actions Bot added the claude label Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: oven-sh/bun/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Essentials

Run ID: 995aa391-d206-4a27-8cfd-2519fcf58389

📥 Commits

Reviewing files that changed from the base of the PR and between 4b02e10 and 7c7c915.

📒 Files selected for processing (6)
  • completions/bun.bash
  • completions/bun.zsh
  • src/bundler/transpiler.rs
  • src/options_types/context.rs
  • src/runtime/cli/Arguments.rs
  • src/runtime/cli/build_command.rs
💤 Files with no reviewable changes (4)
  • src/bundler/transpiler.rs
  • src/options_types/context.rs
  • src/runtime/cli/Arguments.rs
  • src/runtime/cli/build_command.rs

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


Walkthrough

The build CLI no longer exposes the environment-dump option or its output path. Bash and Zsh completion lists also omit selected long options.

Changes

Environment dump option removal

Layer / File(s) Summary
Remove option, output path, and completions
src/options_types/context.rs, src/runtime/cli/Arguments.rs, src/runtime/cli/build_command.rs, src/bundler/transpiler.rs, completions/bun.bash, completions/bun.zsh
Removes the DebugOptions field, build parameter, and code that printed the loaded environment map as JSON. Bash completion no longer lists --dump-environment-variables, --dump-limits, or --disable-bun-js. Zsh bun run completion no longer lists --dump-environment-variables or --dump-limits; --silent now ends the option list.

Suggested reviewers: jarred-sumner

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 7c7c9

The removed option had no effect on build output, and the completion changes remove stale entries. No material merge risk is established by the inspected changes.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely identifies the primary change: removing the dead --dump-environment-variables flag from bun build.
Description check ✅ Passed The description explains the problem, implementation changes, behavior difference, verification steps, test results, and downsides. It uses different headings from the template, but it covers both req…
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Status: ready for review.

Reproduction (bun 1.4.3 and main, Linux x64):

mkdir t && cd t && echo 'console.log("hi")' > x.js
bun build --dump-environment-variables ./x.js

The command prints the bundle and exits 0, the same as without the flag. BUILD_ONLY_PARAMS declares the flag, and no code reads it.

This PR (#44370) removes the flag and the code that only the flag could reach. No maintainer has ruled on the flag. If a maintainer wants the flag connected instead, close this PR.

@claude claude 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.

LGTM, a straightforward dead-code removal.

What was reviewed:

  • Confirmed the deleted DebugOptions.dump_environment_variables field, the BuildCommand branch, and Transpiler::dump_environment_variables have no remaining references anywhere in src/, test/, or docs/ at HEAD, so no struct-literal or call site is left dangling.
  • Checked the --dump-environment-variables=value behavior change (exit 1 before, silently skipped now): the flag was never read, so this only affects an error path for a non-functional flag.
  • Checked the broader completions cleanup (--dump-limits, --disable-bun-js): neither name appears in any param table in src/, so the completion entries were already stale.
Extended reasoning...

The change deletes an unread CLI param, its DebugOptions field and default, the unreachable early-return in build_command.rs, the Transpiler method it called, and the corresponding shell completion entries, for +2/-45 across six files. It touches no security-sensitive surface. A repo-wide grep at HEAD finds no remaining references to any of the removed identifiers or flag names, and none of the changed paths fall under a CODEOWNERS entry. The only behavioral delta is that passing the flag with a value no longer errors, which is an acceptable consequence of removing an inert flag.

@Jarred-Sumner
Jarred-Sumner merged commit 468efac into main Oct 2, 2026
10 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the robobun/1a0f62a8/remove-dump-environment-variables branch October 2, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants