Skip to content

Conversation

@capaj
Copy link
Contributor

@capaj capaj commented Jan 16, 2026

Clarified the description of how Bun reads env files and added information on using --env-file to specify a different path.

What does this PR do?

just docs

How did you verify your code works?

markdown parser still parses :D

Clarified the description of how Bun reads env files and added information on using --env-file to specify a different path.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

Walkthrough

Documentation updates clarifying environment file loading behavior in the current working directory, including support for .env.local, the --env-file flag for arbitrary paths, and command-line variable precedence rules.

Changes

Cohort / File(s) Summary
Environment file loading documentation
docs/guides/runtime/set-env.mdx
Expanded specification of where env files are loaded from (current working directory), added .env.local support with test environment exception, introduced --env-file flag for arbitrary path loading, and clarified command-line precedence over .env files.

Possibly related PRs

Suggested reviewers

  • RiskyMH
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: amendments to environment file instructions and command line usage in set-env.mdx documentation.
Description check ✅ Passed The description follows the template with both required sections completed, explaining what the PR does and how verification was performed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@docs/guides/runtime/set-env.mdx`:
- Around line 29-32: Remove trailing whitespace on the two affected lines
containing the shell example string `bun --env-file=../.env index.ts` so the
lines end immediately after the command; update both occurrences to have no
trailing spaces to ensure consistent formatting in
docs/guides/runtime/set-env.mdx.
- Around line 54-55: Update the sentence "Variables from the command line
override .env" to end with a period and format the filename consistently by
wrapping .env in backticks; i.e., change it to "Variables from the command line
override `.env`." This fixes punctuation and matches the document's
file-reference styling.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bcbb4fc and 2ab9a1e.

📒 Files selected for processing (1)
  • docs/guides/runtime/set-env.mdx
🧰 Additional context used
🧠 Learnings (11)
📚 Learning: 2025-11-24T18:37:11.466Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:37:11.466Z
Learning: Write JS builtins for Bun's Node.js compatibility and APIs, and run `bun bd` after changes

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2026-01-05T23:04:01.518Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/CLAUDE.md:0-0
Timestamp: 2026-01-05T23:04:01.518Z
Learning: Applies to test/**/*.test.{ts,js,jsx,tsx,mjs,cjs} : Use `bun:test` for files ending in `*.test.{ts,js,jsx,tsx,mjs,cjs}`. For test files without .test extension in test/js/node/test/{parallel,sequential}/*.js, use `bun bd <file>` instead of `bun bd test <file>` since they expect exit code 0.

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2026-01-05T23:04:01.518Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/CLAUDE.md:0-0
Timestamp: 2026-01-05T23:04:01.518Z
Learning: Use `-e` flag for single-file tests when spawning Bun processes with `Bun.spawn()`.

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2026-01-14T21:08:10.438Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/js/node/test/parallel/CLAUDE.md:0-0
Timestamp: 2026-01-14T21:08:10.438Z
Learning: Run Node.js compatibility tests using `bun bd <file-path>` command, not `bun bd test <file-path>`

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2026-01-05T23:04:01.518Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/CLAUDE.md:0-0
Timestamp: 2026-01-05T23:04:01.518Z
Learning: Applies to test/**/*.test.{ts,js,jsx,tsx,mjs,cjs} : Use `bun bd test <...test file>` to run tests with compiled code changes. Do not use `bun test` as it will not include your changes.

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2026-01-05T23:04:01.518Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/CLAUDE.md:0-0
Timestamp: 2026-01-05T23:04:01.518Z
Learning: When spawning Bun processes in tests, use `bunExe` and `bunEnv` from `harness` to ensure the same build of Bun is used and debug logging is silenced.

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2026-01-14T21:08:10.438Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: test/js/node/test/parallel/CLAUDE.md:0-0
Timestamp: 2026-01-14T21:08:10.438Z
Learning: These are Node.js compatibility tests not written by Bun and cannot be modified

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2025-11-20T19:51:32.288Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 24880
File: packages/bun-vscode/package.json:382-385
Timestamp: 2025-11-20T19:51:32.288Z
Learning: In the Bun repository, dependencies may be explicitly added to package.json files (even when not directly imported in code) to force version upgrades on transitive dependencies, particularly as part of Aikido security scanner remediation to ensure vulnerable transitive dependencies resolve to patched versions.

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2025-10-26T01:32:04.844Z
Learnt from: Jarred-Sumner
Repo: oven-sh/bun PR: 24082
File: test/cli/test/coverage.test.ts:60-112
Timestamp: 2025-10-26T01:32:04.844Z
Learning: In the Bun repository test files (test/cli/test/*.test.ts), when spawning Bun CLI commands with Bun.spawnSync for testing, prefer using stdio: ["inherit", "inherit", "inherit"] to inherit stdio streams rather than piping them.

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2025-09-12T22:30:48.490Z
Learnt from: RiskyMH
Repo: oven-sh/bun PR: 22613
File: src/cli/package_manager_command.zig:0-0
Timestamp: 2025-09-12T22:30:48.490Z
Learning: Commands like `bun info` and `bun whoami` that are promoted from pm-only subcommands to top-level commands use manual `bun.argv` parsing to detect direct invocation vs. pm invocation. This is different from regular commands that should use `ctx.positionals`.

Applied to files:

  • docs/guides/runtime/set-env.mdx
📚 Learning: 2025-10-16T17:32:03.074Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/install/PackageManager/PackageManagerOptions.zig:187-193
Timestamp: 2025-10-16T17:32:03.074Z
Learning: In Bun's codebase (particularly in files like src/install/PackageManager/PackageManagerOptions.zig), mixing bun.EnvVar.*.get() and bun.EnvVar.*.platformGet() for environment variable lookups is intentional and safe. The code is protected by compile-time platform checks (Environment.isWindows, etc.), and compilation will fail if the wrong function is used on the wrong platform. This pattern should not be flagged as a consistency issue.

Applied to files:

  • docs/guides/runtime/set-env.mdx
🔇 Additional comments (1)
docs/guides/runtime/set-env.mdx (1)

18-22: LGTM!

Good clarifications: specifying "current working directory" removes ambiguity, and adding .env.local with the NODE_ENV=test caveat is helpful for users.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +29 to +32
To read an env file from any other file system path, you must use `--env-file`.
```sh
bun --env-file=../.env index.ts
```
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor: Trailing whitespace.

Lines 29 and 31 have trailing whitespace which should be removed for consistency.

Proposed fix
-To read an env file from any other file system path, you must use `--env-file`. 
+To read an env file from any other file system path, you must use `--env-file`.
 ```sh
-bun --env-file=../.env index.ts 
+bun --env-file=../.env index.ts

</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
To read an env file from any other file system path, you must use `--env-file`.
🤖 Prompt for AI Agents
In `@docs/guides/runtime/set-env.mdx` around lines 29 - 32, Remove trailing
whitespace on the two affected lines containing the shell example string `bun
--env-file=../.env index.ts` so the lines end immediately after the command;
update both occurrences to have no trailing spaces to ensure consistent
formatting in docs/guides/runtime/set-env.mdx.

Comment on lines +54 to +55
Variables from the command line override .env

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor: Missing period at end of sentence.

For consistency with the rest of the document's style, add a period at the end of the sentence.

Proposed fix
-Variables from the command line override .env
+Variables from the command line override `.env`.

Note: Wrapping .env in backticks would also improve consistency with how other file references are formatted in the document.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Variables from the command line override .env
Variables from the command line override `.env`.
🤖 Prompt for AI Agents
In `@docs/guides/runtime/set-env.mdx` around lines 54 - 55, Update the sentence
"Variables from the command line override .env" to end with a period and format
the filename consistently by wrapping .env in backticks; i.e., change it to
"Variables from the command line override `.env`." This fixes punctuation and
matches the document's file-reference styling.

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.

1 participant