fix(cli): tolerate unreadable dirs when building systemd PATH#26740
Closed
austinpickett wants to merge 2 commits into
Closed
fix(cli): tolerate unreadable dirs when building systemd PATH#26740austinpickett wants to merge 2 commits into
austinpickett wants to merge 2 commits into
Conversation
generate_systemd_unit runs _build_service_path_dirs(); tests that mimic sudo (Path.home → /root) caused is_dir() to raise PermissionError for unprivileged users on /root/.hermes/..., failing CI. Treat inaccessible paths like missing. Co-authored-by: Cursor <cursoragent@cursor.com>
19 tasks
Contributor
🔎 Lint report:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes systemd PATH construction more tolerant of inaccessible optional bindirs by wrapping directory probes so OSError/PermissionError skips unusable entries instead of aborting unit generation.
Changes:
- Adds
_path_usable_bindir()to safely check candidate PATH directories. - Replaces direct
.is_dir()checks in_build_service_path_dirs()with the safe helper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Clarify that _path_usable_bindir is a stat-style is_dir probe; add unit tests for OSError suppression and positive directory case per review feedback. Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Author
|
Addressed the two inline review threads in 1a37f20:
|
Collaborator
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.
What does this PR do?
generate_systemd_unitcalls_build_service_path_dirs(), which probes optional PATH entries viaPath.is_dir(). Unit tests simulatesudoby patchingPath.home()to/root, so Hermes paths resolve under/root/.hermes/.... Normal users cannotstat/root; that raisedPermissionErrorand brokeTestSystemUnitHermesHome(and CI on Linux runners).Treat unreadable/absent probes like “not usable”:
_path_usable_bindirwraps.is_dir()withexcept OSErrorso PATH construction skips those entries instead of failing.Related Issue
CI-only / test breakage; no ticket linked.
Type of Change
Changes Made
hermes_cli/gateway.py— add_path_usable_bindir(); use it in_build_service_path_dirs()instead of bare.is_dir().How to Test
pytest tests/hermes_cli/test_gateway_service.py::TestSystemUnitHermesHome -qChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
Not applicable.
Screenshots / Logs
N/A