fix(desktop): avoid updater-created Linux launchers - #82040
darzi-admin wants to merge 4 commits into
Conversation
monerostar
left a comment
There was a problem hiding this comment.
Ubuntu 26.04 on linux-5800x here. Live-checked this against current main.
Order bug on main: _register_linux_desktop_entry() still runs before the --build-only early return, so headless updater rebuilds rewrite ~/.local/share/applications/hermes.desktop. This tip returns on build_only first, then registers only on real launches. is_supported() is True on this box; desktop path resolves to ~/.local/share/applications/hermes.desktop.
Exec fallback matrix (forced resolve_hermes_bin=None, synthetic venv bin/python symlink to a base interpreter):
- main:
Execbecomes the resolved base interpreter (.../base-python -m hermes_cli.main desktop) - this PR: keeps
.../venv/bin/pythonviaos.path.abspath(does not drop pyvenv.cfg context)
Shebang helper on the PR tip:
#!/usr/bin/env python3wrapper -> True (falls back to interpreter path)- hardcoded
.../envs/foo/bin/python-> False (no false positive on directory nameenvs) #!/bin/sh-> False
When resolve_hermes_bin points at an env wrapper, PR Exec uses the abspath venv python module form, not the wrapper.
Focused tests on the PR tree:
pytest tests/hermes_cli/test_linux_desktop_entry.py tests/hermes_cli/test_gui_command.py -q -o addopts=
-> 33 passed in 0.77s
Note: GitHub currently reports no checks on branch fix/linux-desktop-updater-launcher from this host. Local Linux evidence above is green.
Related open Linux desktop-entry work (#80563, #80547, etc.) is mostly Exec rewrite / argv0. This one is the build-only registration skip plus the env-wrapper and venv-symlink pieces. Looks good.
Summary
hermes desktop --build-onlyself-update step from creating or rewriting Linux application launchers#!/usr/bin/env python3source wrappers intoExec=/usr/bin/env python*shebangs from hardcoded interpreter paths containing directory names such as/envs/Why
Desktop self-update rebuilds through
hermes desktop --build-only. Launcher registration previously ran before the build-only return, so the updater created a secondhermes.desktopentry and could persist a repository source wrapper whose/usr/bin/env python3resolves differently in a desktop session. The generated launcher then failed at startup when the desktop-session Python lacked Hermes dependencies.The fallback must also retain
venv/bin/pythonitself: resolving that symlink to the base interpreter discards the venv site-packages when launched from an unrelated working directory.Test plan
venv/bin/python -m pytest tests/hermes_cli/test_linux_desktop_entry.py tests/hermes_cli/test_gui_command.py tests/hermes_cli/test_relaunch.py -o 'addopts=' -q— 49 passedgit diff --check -- hermes_cli/linux_desktop_entry.py hermes_cli/main.py tests/hermes_cli/test_linux_desktop_entry.py tests/hermes_cli/test_gui_command.pyhermes_cli; resolved base interpreter reproducesModuleNotFoundErrorhermes desktop --build-onlycompleted successfully and did not recreate the removed duplicate launcher