Skip to content
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

docs: improve command line environment variable tips #16490

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

dy0gu
Copy link

@dy0gu dy0gu commented Jan 18, 2025

What does this PR do?

  • Documentation

Improves the existing docs section for setting variables through the command line.

The method currently described in the docs is the following:

$ FOO=helloworld bun run dev

The problem is this syntax is only available on POSIX-compliant shells, which mostly means MacOS and Linux. I assumed that bit was a leftover from when Bun did not support Windows and had yet to be updated.

I've recently seen a significant number of Windows users being confused as to why following the docs on this was not working, so I decided to clarify where that syntax is available.

In addition to that I added a cross-platform alternative for setting variables like previously expected, although I'm open to feedback if you think it's not clean enough to be in the official docs. It makes use of a somewhat chained and lengthy bun exec syntax.

I believe the presence of the examples added by this PR are important as I found myself and other peers regularly needing specific package.json commands to set the NODE_ENV variable, for example.

docs/runtime/env.md Outdated Show resolved Hide resolved
docs/runtime/env.md Outdated Show resolved Hide resolved
@RiskyMH

This comment was marked as outdated.

@dy0gu
Copy link
Author

dy0gu commented Jan 18, 2025

I update the mention of bun exec on Windows to bun shell instead, for clarity.

I also shortened the longer bit of text, I think all the needed info is still nicely there.

Side note, it's nice to finally give back to Bun, the experience has been great and the built-in environment utilities are probably one of the biggest reasons for having migrated personally. Also, thanks for your review @RiskyMH, let me know if any more changes are needed!

@RiskyMH
Copy link
Member

RiskyMH commented Jan 18, 2025

nice glad to hear!

to make it more clear i put it in a dropdown which i believe will catch your eye better also.. let me know if you preferred it the other way though.

normal expanded
image image

@dy0gu
Copy link
Author

dy0gu commented Jan 18, 2025

Looks good to me 👍

@RiskyMH RiskyMH requested a review from paperclover January 18, 2025 05:27
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