You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use [git worktrees](https://git-scm.com/docs/git-worktree) to work on multiple branches in parallel, each worktree's `bin/dev` will conflict on the default ports (3000 for Rails, 3035 for webpack-dev-server).
337
+
If you use [git worktrees](https://git-scm.com/docs/git-worktree) to work on multiple branches
338
+
in parallel, `bin/dev` automatically detects and avoids port conflicts — no configuration needed.
338
339
339
-
Create a `.env` file in each worktree (gitignored by default in Rails apps). Both foreman and overmind read `.env` automatically on startup.
340
+
When the default ports (3000 for Rails, 3035 for webpack-dev-server) are occupied, `bin/dev`
341
+
scans for the next free pair and prints:
340
342
341
-
The generated `Procfile.dev` uses `${PORT:-3000}`, so setting `PORT` is enough for Rails. For the webpack dev server, Shakapacker reads `SHAKAPACKER_DEV_SERVER_PORT` natively on both the Ruby proxy and the webpack-dev-server JS sides — no `shakapacker.yml` changes needed.
342
-
343
-
**Worktree 1** — use defaults (no `.env` needed), or set explicitly:
344
-
345
-
```sh
346
-
PORT=3000
347
-
SHAKAPACKER_DEV_SERVER_PORT=3035
343
+
```
344
+
Default ports in use. Using Rails :3001, webpack :3036
348
345
```
349
346
350
-
**Worktree 2 `.env`:**
347
+
**To override ports manually**, create a `.env` file in the worktree (gitignored by default).
348
+
A `.env.example` is generated by `rails g react_on_rails:install` as a reference:
351
349
352
350
```sh
353
351
PORT=3001
354
352
SHAKAPACKER_DEV_SERVER_PORT=3036
355
353
```
356
354
357
-
A `.env.example` is generated by `rails g react_on_rails:install` as a starting point. Copy it to `.env` and adjust ports as needed.
355
+
When `PORT` or `SHAKAPACKER_DEV_SERVER_PORT` are set, auto-detection is skipped entirely.
0 commit comments