Skip to content

init: do not fail if no shell and no GUI is available - #7843

Merged
wenzeslaus merged 3 commits into
OSGeo:mainfrom
marisn:gui_start_fail
Oct 17, 2026
Merged

wenzeslaus merged 3 commits into
OSGeo:mainfrom
marisn:gui_start_fail

Conversation

@marisn

@marisn marisn commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

check_gui can return None and there is no guard before call gui_process.wait().

As this state can be reached only on a broken setup, it makes sense to just warn user and exit.
Discovered by a wrong Docker usage – not common, but also possible to reach.

Co-authored with Claude Opus 5

Test: env -u DISPLAY grass /path/to/mapset < /dev/null

`check_gui` can return None and there is no guard before call
`gui_process.wait()`.

As this state can be reached only on a broken setup, it makes sense
to just warn user and exit.

Co-authored with Claude Opus 5
@marisn
marisn requested a review from petrasovaa August 24, 2026 13:35
@github-actions github-actions Bot added Python Related code is in Python libraries labels Aug 24, 2026
@marisn marisn changed the title Init: do not fail if no shell and no GUI is available init: do not fail if no shell and no GUI is available Aug 24, 2026
echoix
echoix previously approved these changes Aug 24, 2026

@echoix echoix left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see nothing wrong with this

@petrasovaa
petrasovaa requested review from wenzeslaus and removed request for petrasovaa August 24, 2026 14:15

@wenzeslaus wenzeslaus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needless to say, this code would need much more work to make it smoother, but this is good for what it does. Definitively a case we want to handle (we already handle the no TTY/no interactive IO case for both GUI and --exec, so this fits right in).

Besides going back to the simple check, possibly also update lib/init/grass.md (around line 118?), which describes the text-mode as unconditional fallback. So perhaps add a condition ("...if [interactive] term... is available...") or describe when GRASS exits with an error.

Comment thread lib/init/grass.py Resolved
Remove unnecessary GUI type check

Co-authored-by: Vaclav Petras <wenzeslaus@gmail.com>
@github-actions github-actions Bot added docs markdown Related to markdown, markdown files labels Aug 30, 2026
@marisn
marisn requested a review from wenzeslaus August 30, 2026 08:34
@wenzeslaus
wenzeslaus enabled auto-merge (squash) October 17, 2026 05:32

@wenzeslaus wenzeslaus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It took me some time to circle back to this.

Tests generated by AI

Tested with the PR's grass.py against an existing build (before = base, after = PR head):

  • env -u DISPLAY grass MAPSET < /dev/null (the PR's own test):
    before: AttributeError: 'NoneType' object has no attribute 'wait';
    after: clean ERROR message, exit 1.
  • env DISPLAY=:0 GRASS_PYTHON=/bin/false grass MAPSET < /dev/null
    (GUI unusable for a non-DISPLAY reason): before: same traceback;
    after: same ERROR message, exit 1.
  • env -u DISPLAY grass --text MAPSET < /dev/null and
    env -u DISPLAY grass --text MAPSET <<<'g.gisenv get=MAPSET':
    text mode unchanged; piped stdin still runs the command.
  • env -u DISPLAY GRASS_DEBUG=1 grass --text MAPSET < /dev/null:
    DEBUG: GRASS GUI should be <text> still present (briefly lost with the
    earlier call-site condition, restored by its removal).

@wenzeslaus
wenzeslaus merged commit d0be352 into OSGeo:main Oct 17, 2026
26 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs libraries markdown Related to markdown, markdown files Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants