fix(editor): use a literal dev port so bun dev works on Windows - #551
Open
evolv3ai wants to merge 1 commit into
Open
fix(editor): use a literal dev port so bun dev works on Windows#551evolv3ai wants to merge 1 commit into
bun dev works on Windows#551evolv3ai wants to merge 1 commit into
Conversation
On Windows, `bun run` executes package scripts with Bun's own built-in
shell rather than a POSIX shell. That shell does not implement
default-value parameter expansion, so `${PORT:-3002}` is passed through
to Next.js verbatim and the dev server exits immediately:
error: option '-p, --port <port>' argument '${PORT:-3002}' is invalid.
'${PORT:-3002}' is not a non-negative number.
Setting PORT in the environment does not help — the literal is never
expanded either way.
Replace the expansion with the documented default port (3002).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bun devfails immediately on Windows. Theeditordev task dies before Next.js starts:Cause
On Windows,
bun runexecutes package scripts with Bun's own built-in shell rather than handing them to a POSIX shell. That shell does not implement default-value parameter expansion, so${PORT:-3002}inapps/editor/package.jsonreaches Next.js verbatim and is rejected.Setting
PORTin the environment first does not work around it — the literal is never expanded either way. There is no shell-level workaround from the caller's side; the script itself has to avoid the syntax.Fix
Use the documented default port directly:
Verified on Windows 11 / Bun 1.3.6 / Node 24.18.0 —
bun devnow boots the whole workspace and the editor servesHTTP 200on http://localhost:3002.Tradeoff, and an alternative if you'd prefer it
This drops the
PORToverride that SETUP.md documents. I kept the change to one line because that's the smallest thing that unblocks Windows, but I'm happy to switch to a small cross-platform launcher instead, which would preservePORTon every platform:Just say which you'd rather have and I'll update the PR.
Two unrelated things I noticed while debugging
Not touched in this PR, but worth flagging:
The root
devscript is also a no-op on Windows. It begins withset -a && . ./.env 2>/dev/null; set +a; turbo run dev --env-mode=loose. Bun's shell has nosetbuiltin, so it printsbun: command not found: settwice and silently skips loading.env. Turbo still runs, so it's non-fatal, but any variables in a root.envare never loaded on Windows..env.exampleandSETUP.mddisagree on the default port..env.examplesays# Dev server port (default: 3000)/# PORT=3000, while SETUP.md and the dev script both use 3002.Note
Low Risk
Single-line dev script change with no runtime, security, or production impact; only affects local editor startup and removes PORT override from that script.
Overview
Fixes
bun devon Windows by changing the editordevscript from--port ${PORT:-3002}to--port 3002. Bun’s script runner on Windows does not expand POSIX default-value syntax, so Next.js was receiving the literal string and exiting immediately.Tradeoff: overriding the dev port via the
PORTenvironment variable from this script no longer works; the default is always 3002 unless the approach is changed to a small cross-platform launcher (as noted in the PR description).Reviewed by Cursor Bugbot for commit 452018e. Bugbot is set up for automated code reviews on this repo. Configure here.