Skip to content

gui/wxpython: dynamically check GRASS_ADDON_BASE for newly installed modules#7642

Open
ArthPatel1502 wants to merge 1 commit into
OSGeo:mainfrom
ArthPatel1502:fix-addon-gui-7483
Open

gui/wxpython: dynamically check GRASS_ADDON_BASE for newly installed modules#7642
ArthPatel1502 wants to merge 1 commit into
OSGeo:mainfrom
ArthPatel1502:fix-addon-gui-7483

Conversation

@ArthPatel1502

Copy link
Copy Markdown
Contributor

Description

This PR resolves issue #7483 where a newly installed addon fails to open its wxGUI dialog window during the same session on macOS.

Root Cause

When the wxGUI initializes, globalvar.grassCmd caches the list of available GRASS commands. Running g.extension mid-session installs the binary correctly, but the string list cache is never refreshed. Because the command evaluates to False against the stale globalvar.grassCmd list, it defaults to background CLI execution instead of opening GUI().ParseCommand().

Forcing the tool with --ui runs it as an isolated process detached from the layer manager framework, triggering subsequent NotImplementedError failures when trying to fetch coordinates via the selection cursor.

Fix

Added a non-intrusive dynamic check using shutil.which inside GConsole.RunCmd. If an executed command isn't tracked inside the startup globalvar.grassCmd cache, it actively looks inside the live environment's GRASS_ADDON_BASE/bin or scripts folders. If discovered, it updates the runtime cache pool on the fly so the dialog wrapper intercepts and builds the GUI interface seamlessly.

@github-actions github-actions Bot added GUI wxGUI related Python Related code is in Python labels Jul 5, 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.

Do you know what « command » will look like when running on windows? Would it we found on these paths?

@ninsbl

ninsbl commented Jul 5, 2026

Copy link
Copy Markdown
Member

Please note that users may be able to install AddOns system wide with g.extension -s in which case newly installed AddOns will not end up in the GRASS_ADDONS_PATH but in GISBASE... Obviously a corner case, but still a possibility...

@ArthPatel1502

Copy link
Copy Markdown
Contributor Author

Thank you both for the excellent feedback!

@echoix Regarding Windows: shutil.which automatically uses the system's PATHEXT environment variable on Windows to resolve extensions like .exe, .bat, or .py. However, to be fully safe across OS variations and ensure we match how GRASS maps paths on Windows, I will adjust the patch to include the base addon paths explicitly.

@ninsbl Good catch on the system-wide -s flag. To account for this corner case, I will update the search paths to include GISBASE/bin and GISBASE/scripts as fallback checks as well.

I will update the implementation block to include these fallback paths and push the updated commit shortly!

…eo#7241)

* backward compatibility for curly braces
* map variable replacement on Display change
---------

Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
Co-authored-by: Martin Landa <landa.martin@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GUI wxGUI related Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants