GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@dpage dpage commented Nov 4, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

All reactions
@dpage
Fix the PSQL tool failing to start psql on Windows.
b5bf60b
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

coderabbitai Bot commented Nov 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Explain Change →

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed 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 Passed 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)
  • Create a new PR
  • 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
  • X
  • Mastodon
  • Reddit
  • LinkedIn
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: pgadmin-org/pgadmin4
  • Branch: master
  • File: .coderabbit.yaml
  • Commit: 758d51d
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ac93af0f-8b8f-43a5-8eab-e7ee1a7e228d
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dpage added a commit that referenced this pull request Nov 4, 2026
@dpage
Fix the PSQL tool failing to start psql on Windows. (#10725)
df554c7
@dpage

dpage commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged as df554c7.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dpage dpage closed this Nov 4, 2026
This was referenced Nov 4, 2026
PSQL tool not working as expected on pgAdmin 9.19 - #10714
Closed
Python dependency: Update pywinpty requirement from ==2.0.* to ==3.1.* #10669
Closed
Python dependency: Update pywinpty requirement from ==2.0.* to ==3.1.* in /web/regression #10756
Closed
PSQL Tool fails on Windows in 9.19 with could not find a "" to execute (works in 9.18) #10759
Closed
@erick-ouellette

erick-ouellette commented Nov 18, 2026

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PSQL tool not working as expected on pgAdmin 9.19 -

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@dpage @erick-ouellette
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.