GeezerVison is showing github.com — Fix the PSQL tool failing to start psql on Windows by dpage · Pull Request #10725 · pgadmin-org/pgadmin4
Conversation
dpage
commented
Nov 4, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #10714.
Since #10453 spawned psql directly through pywinpty instead of via cmd.exe, psql has started with an empty argv[0] on Windows and failed with could not find a "" to execute and could not find own program executable. pywinpty passes argv[0] to CreateProcess as the application name, but builds the command line from argv[1:] alone (winpty/ptyprocess.py, the same in 2.0.15 and 3.1.2), so psql never sees its own name. This repeats the executable as the first argument, so that it also leads the command line.
The unit test only checks the arguments passed to spawn, so this still needs a check on Windows that the PSQL tool connects. Whoever does that could also try pywinpty 3.1.2 (#10669) at the same time, watching for psql output only appearing after a keypress, which was the original reason for the 2.0 pin.
Summary by CodeRabbit
- Bug Fixes
- Improved psql session startup on Windows by correcting the command-line invocation passed to the terminal process. Environment handling remains unchanged, and no other platform behavior is affected. This update concerns Windows command launching only; it does not change connection settings or add user-facing options.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Since psql has been spawned directly through pywinpty (pgadmin-org#10453), it has
started with an empty argv[0], because pywinpty passes argv[0] to
CreateProcess as the application name but builds the command line from
argv[1:] alone. psql then fails with "could not find own program
executable". Repeat the executable so that it is also the first word of
the command line.
Fixes pgadmin-org#10714
coderabbitai
Bot
commented
Nov 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
On Windows, windows_platform now passes the executable name twice at the start of the PSQL spawn arguments. The EOF-before-exit test checks those arguments and the empty environment.
Changes
Windows PSQL startup
| Layer / File(s) |
Summary |
Set and verify Windows spawn arguments web/pgadmin/tools/psql/__init__.py, web/pgadmin/tools/psql/tests/test_windows_pty_failures.py |
windows_platform duplicates the executable name in the spawn arguments and continues to pass the user environment. The EOF-before-exit test expects the duplicated name, database argument, and empty environment. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: kundansable
Merge Risk: Minimal · up to b5bf6
-
This change repeats the executable name in the PSQL spawn arguments so the PSQL tool can start on Windows. No concrete defect was found. Confirming on Windows that the PSQL tool connects is still recommended before release.
Pre-merge checks: 4 · 1
-
Failed checks: 1 warning
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
 |
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
Passed checks: 4 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title names the main change. The PR fixes the psql tool failing to start on Windows. The raw summary shows the Windows spawn path now repeats the executable as the first argument, which addresses … |
| Linked Issues check |
 |
Issue #10714 requires the PSQL Tool to start psql on Windows without the errors 'could not find a "" to execute' and 'could not find own program executable'. The only coding requirement is this startu… |
| Out of Scope Changes check |
 |
The reviewed head changes two files. In web/pgadmin/tools/psql/init.py, the change is a targeted edit in windows_platform plus a comment that explains the pywinpty argv[0] behavior and cites #1071… |
Full details: Title check
-
Explanation
The title names the main change. The PR fixes the psql tool failing to start on Windows. The raw summary shows the Windows spawn path now repeats the executable as the first argument, which addresses that startup failure. The title is specific and matches the linked issue and the PR objectives.
Full details: Linked Issues check
-
Explanation
Issue #10714 requires the PSQL Tool to start psql on Windows without the errors 'could not find a "" to execute' and 'could not find own program executable'. The only coding requirement is this startup fix. The reviewed head changes web/pgadmin/tools/psql/init.py in windows_platform. It now calls PtyProcess.spawn with [connection_data[0]] + list(connection_data), so the executable is also argv[0] in the command line. The previous code passed connection_data unchanged. The issue error text matches an empty argv[0]. The PR description states that pywinpty uses argv[0] only as the application name and builds the command line from argv[1:]. This change addresses that cause directly. Limits: the pywinpty behavior is external and was not verified in this repository. The test file diff could not be read, so the summary is the only evidence for its assertion. No Windows runtime run is present. The PR description itself says a Windows connection check is still needed. The fix is consistent with the reported failure, so the requirement is met on the evidence available.
Full details: Out of Scope Changes check
-
Explanation
The reviewed head changes two files. In web/pgadmin/tools/psql/init.py, the change is a targeted edit in windows_platform plus a comment that explains the pywinpty argv[0] behavior and cites #10714. It directly implements the linked issue. In web/pgadmin/tools/psql/tests/test_windows_pty_failures.py, the summary reports a four-line addition. It asserts that spawn receives ['psql', 'psql', 'dbname=postgres'] with an empty environment. This is a supporting test for the same change. No unrelated refactoring, documentation, or feature work is described. The PR description's suggested pywinpty 3.1.2 trial is not part of the diff. The test file diff could not be read directly, so this verdict relies on the summary for that file. That file's content is described as supporting and narrow.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 758d51d and b5bf60b.
Files selected for processing: 2
-
web/pgadmin/tools/psql/__init__.py
web/pgadmin/tools/psql/tests/test_windows_pty_failures.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 4, 2026
|
Will this fix be backported and rebuilt into 9.19, or do users have to wait until 9.20? I cannot cleanly downgrade to the more stable 9.17.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|