-
Notifications
You must be signed in to change notification settings - Fork 8
fix(connection): default_host() checks directory existence instead of socket file #721
Copy link
Copy link
Closed
Description
Problem
default_host() in src/connection.rs (~line 365) checks whether the candidate socket directory exists (is_dir()), not whether a socket file exists inside it.
On this machine /var/run/postgresql exists (contains 13-main.pg_stat_tmp) but has no .s.PGSQL.5432 socket. rpg picks it as the default host and then fails with:
rpg: connection to server at "/var/run/postgresql", port 5432 failed: No such file or directory (os error 2)
psql handles this correctly — it checks for the actual socket file before selecting a default.
Fix
Replace the is_dir() check with a check for the socket file:
// Instead of:
PathBuf::from(dir).is_dir()
// Check for the actual socket file:
PathBuf::from(dir).join(format!(".s.PGSQL.{}", port)).exists()The port is needed for the socket filename. If port is not yet resolved at this point, fall through to the next candidate rather than selecting a directory that has no active socket.
Discovered
Full connection matrix audit, 2026-03-24 (Section B).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels