fix(manager): add common macOS paths to system module search#125
Merged
ErikBjare merged 2 commits intoActivityWatch:masterfrom Mar 12, 2026
Merged
Conversation
When aw-qt is launched from Finder on macOS the PATH is minimal (/usr/bin:/bin:/usr/sbin:/sbin) and doesn't include directories where AW modules are typically installed. This caused _discover_modules_system() to find 0 system modules when not launched from a terminal. Add common macOS binary paths explicitly to the search so that system modules can be found regardless of how aw-qt was launched: - /opt/homebrew/bin (Homebrew on Apple Silicon) - /usr/local/bin (Homebrew on Intel / pip global installs) - ~/.local/bin (pip --user installs) Duplicates are skipped (paths already in PATH are not added again), and only existing directories are searched. Fixes ActivityWatch#96 Co-authored-by: Bob <bob@superuserlabs.org>
Contributor
Greptile SummaryThis PR fixes a macOS-specific module discovery failure where aw-qt launched from Finder inherits a minimal Key points:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["_discover_modules_system()"] --> B["search_paths = os.get_exec_path()"]
B --> C{"_parent_dir in search_paths?"}
C -- Yes --> D["Remove _parent_dir"]
C -- No --> E{"platform == Darwin?"}
D --> E
E -- No --> I
E -- Yes --> F["macos_extra_paths = [/opt/homebrew/bin, /usr/local/bin, ~/.local/bin]"]
F --> G{"extra_path already in search_paths?"}
G -- Yes --> G2["Skip (no duplicate)"]
G -- No --> H{"os.path.isdir(extra_path)?"}
H -- No --> H2["Skip (doesn't exist)"]
H -- Yes --> H3["Append to search_paths"]
G2 --> I["paths = [p for p in search_paths if os.path.isdir(p)]"]
H2 --> I
H3 --> I
I --> J["For each path: os.listdir → find aw-* executables"]
J --> K["Return discovered modules"]
Last reviewed commit: 93f3a20 |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
marcstober
pushed a commit
to marcstober/aw-qt
that referenced
this pull request
Mar 18, 2026
…yWatch#125) * fix(manager): add common macOS paths to system module search When aw-qt is launched from Finder on macOS the PATH is minimal (/usr/bin:/bin:/usr/sbin:/sbin) and doesn't include directories where AW modules are typically installed. This caused _discover_modules_system() to find 0 system modules when not launched from a terminal. Add common macOS binary paths explicitly to the search so that system modules can be found regardless of how aw-qt was launched: - /opt/homebrew/bin (Homebrew on Apple Silicon) - /usr/local/bin (Homebrew on Intel / pip global installs) - ~/.local/bin (pip --user installs) Duplicates are skipped (paths already in PATH are not added again), and only existing directories are searched. Fixes ActivityWatch#96 Co-authored-by: Bob <bob@superuserlabs.org> * Update tests/test_manager.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: Erik Bjäreholt <erik.bjareholt@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When aw-qt is launched from Finder on macOS (e.g. double-clicking the .app), the PATH is minimal (
/usr/bin:/bin:/usr/sbin:/sbin) and doesn't include directories where ActivityWatch modules are typically installed. This means_discover_modules_system()finds 0 system modules, causing aw-qt to report errors like:Launching from Terminal works fine because the shell's full PATH is inherited.
Closes #96
Solution
Add common macOS binary paths explicitly to the system module search, so modules are found regardless of how aw-qt is launched:
/opt/homebrew/bin— Homebrew on Apple Silicon/usr/local/bin— Homebrew on Intel / pip global installs~/.local/bin— pip--userinstallsGuards:
os.path.isdircheck)Tests
Added 3 unit tests in
tests/test_manager.py:test_macos_adds_extra_paths_when_not_in_path— verifies Homebrew and pip paths are searched with a minimal Finder-like PATHtest_macos_does_not_duplicate_existing_path_entries— verifies paths already in PATH aren't searched twicetest_non_macos_does_not_add_extra_paths— verifies Linux behavior is unchanged