From f522c53258af91f6e6fa428e994a1e12ffb31e2b Mon Sep 17 00:00:00 2001 From: Geoff Turk Date: Fri, 31 Jul 2026 11:23:37 +0200 Subject: [PATCH] fix(make): probe the dev database with /dev/tcp instead of nc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `make dev` guards on the shared dev database being reachable, so that a missing `make forward-db` tunnel fails with an instruction rather than a bare "connection refused". The guard used `nc -z`, which is not installed by default on every distro — Arch among them. Where it is absent the probe fails for the wrong reason and the target refuses to start with the tunnel up and healthy, which reads as a broken port-forward and sends you debugging kubectl. - `Makefile:56`: open a bash `/dev/tcp` socket instead of shelling out to netcat. No external dependency, and it distinguishes "port closed" from "tool missing" by construction, because there is no tool. The probe is wrapped in an explicit `bash -c` rather than left to make's default `/bin/sh`: `/dev/tcp` is a bash feature, and on Debian-family systems `/bin/sh` is dash, which does not have it. Signed-off-by: Geoff Turk --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d47a933..fc0ec97 100644 --- a/Makefile +++ b/Makefile @@ -52,8 +52,11 @@ tidy: # Start the API with Air hot-reload. The database is the shared one in the dev # cluster, so `make forward-db` must already be running in another terminal — # checked here because otherwise the failure is a bare "connection refused". +# The probe is bash's /dev/tcp rather than nc: netcat is not installed by +# default on every distro, and a missing nc made this check report the tunnel +# as down when it was up. dev: - @nc -z localhost $(DB_PORT) 2>/dev/null || { \ + @bash -c 'exec 3<>/dev/tcp/localhost/$(DB_PORT)' 2>/dev/null || { \ echo "Nothing listening on localhost:$(DB_PORT)."; \ echo "Start the tunnel to the shared dev database first, in another terminal:"; \ echo ""; \