-
Notifications
You must be signed in to change notification settings - Fork 3.9k
docs: amend env file instructions and command line usage for set-env.mdx #26162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Clarified the description of how Bun reads env files and added information on using --env-file to specify a different path.
WalkthroughDocumentation updates clarifying environment file loading behavior in the current working directory, including support for Changes
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ 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. Comment |
There was a problem hiding this 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.
📒 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.localwith theNODE_ENV=testcaveat is helpful for users.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| To read an env file from any other file system path, you must use `--env-file`. | ||
| ```sh | ||
| bun --env-file=../.env index.ts | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| Variables from the command line override .env | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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.
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