Skip to content

Commit 48f62e8

Browse files
dadachiclaude
andcommitted
Source .env in bin/dev so Overmind inherits HOST/PORT
Overmind (unlike Foreman) does not auto-load .env, so HOST was never reaching Rails through bin/dev at all — Procfile.dev's \${HOST:?...} would have fired on every launch. Source .env in bin/dev before exec'ing Overmind so HOST/PORT are inherited by the spawned processes. Update .env.sample and development.rb comments that incorrectly credited Foreman. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b6e9b5d commit 48f62e8

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

.env.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Copy to .env and set HOST to your current Wi-Fi IP, then Foreman
2-
# auto-loads this when running `bin/dev`.
1+
# Copy to .env and set HOST to your current Wi-Fi IP. `bin/dev`
2+
# sources this before launching Overmind.
33
#
44
# Rails, the iOS app, and the Android app must all agree on one
55
# reachable address — your host's current Wi-Fi IP. On macOS:

bin/dev

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/usr/bin/env sh
22

3+
# Load .env so HOST/PORT are inherited by Overmind and the spawned
4+
# processes. Overmind (unlike Foreman) does not auto-load .env.
5+
if [ -f .env ]; then
6+
set -a
7+
. ./.env
8+
set +a
9+
fi
10+
311
# Default to port 3000 if not specified
412
export PORT="${PORT:-3000}"
513

config/environments/development.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838

3939
config.action_mailer.perform_caching = false
4040

41-
# HOST is only loaded into ENV by Foreman under `bin/dev`; direct Rails
42-
# invocations (console, test, setup, CI) don't see .env, so default to
43-
# localhost for the mailer so boot succeeds. `Procfile.dev` still refuses
41+
# .env is sourced by bin/dev for the dev server only; direct Rails
42+
# invocations (console, test, setup, CI) don't see it, so default to
43+
# localhost for the mailer so boot succeeds. Procfile.dev still refuses
4444
# to start the dev server without an explicit HOST.
4545
config.action_mailer.default_url_options = {host: ENV.fetch("HOST", "localhost"), port: ENV.fetch("PORT", 3000).to_i}
4646

0 commit comments

Comments
 (0)