[PR #100] [MERGED] Launcher: say the self-update succeeded (not "No such file or directory") and restart into it #2329

Closed
opened 2026-11-02 15:55:00 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/100
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/launcher-self-update-message


📝 Commits (1)

  • 158e0c6 Launcher: a self-update after the binary was replaced says it updated, and Restart re-runs it

📊 Changes

3 files changed (+163 additions, -23 deletions)

View changed files

📝 launcher/src/backend.rs (+149 -14)
📝 launcher/src/cli.rs (+1 -1)
📝 launcher/src/main.rs (+13 -8)

📄 Description

What changed

The bug. When the launcher's binary had been replaced under the running process (an update from horizon-launcher update, another launcher window, or an earlier update in the same run), the next self-update failed with "No such file or directory". Reproduced with a minimal program: after the running file is replaced, std::env::current_exe() on Linux returns /path/horizon-launcher (deleted) (it reads /proc/self/exe), and self_replace::self_replace resolves the target from it, so metadata() fails with ENOENT:

current_exe now: Ok("/tmp/selfreplace-repro/target/debug/repro (deleted)")
self_replace: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" })

The fix (launcher/src/backend.rs).

  • Unix (Linux and macOS): the new binary is copied beside the path the launcher started from (exe_path(), read once at start), made executable with the old file's mode, and renamed over it. It no longer asks the system where the running binary is. Windows keeps self_replace, which moves the locked running exe aside.
  • Before downloading, the binary now at that path is asked for its --version (no console window on Windows); when it already is that release or newer, the update counts as done and nothing is downloaded.
  • restart() execs the new binary with the same arguments on Unix (spawn + exit on Windows) and returns an error message instead of exiting silently when it cannot start; the window shows it.

The message. Settings: "Updated to X. Restart the launcher to use it." with the Restart button; sidebar: "Launcher updated to X" / "Restart the launcher"; CLI: "Launcher: updated to X. Restart the launcher to use it."

How tested

  • Unit tests: --version output parsing (and a binary that is not a launcher gives no version); replace_binary puts the new file at the path after another update swapped it, and when the file is gone, executable, with no temp file left.
  • End to end on Linux with the real backend::self_update and restart, a local HTTP server serving a horizon-launcher-linux-x86_64.tar.gz "release" (a small script), from a throwaway program linked to the launcher library:
    • plain update: self_update: Ok(()), the file is the new one, restart execs it with the same arguments;
    • file swapped first (current_exe = … (deleted), the failing case): Ok(()), replaced, restarted;
    • file already updated to 0.1.9 by someone else, no server running: Ok(()) without a download, restart runs it.
  • cargo fmt --check, cargo clippy --all-targets -D warnings, cargo test (launcher), python tools/check_public_tree.py.
  • Not run: macOS and Windows (only Linux per the project's rules; the macOS path is the Unix one, Windows keeps self_replace). No screenshot of the Ready state: it needs a release build and a newer launcher release on GitHub (0.1.4 is the newest).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/100 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/launcher-self-update-message` --- ### 📝 Commits (1) - [`158e0c6`](https://github.com/horizon-rust/horizon/commit/158e0c634674f8f3da57e4bf7971a0f28acd9e0b) Launcher: a self-update after the binary was replaced says it updated, and Restart re-runs it ### 📊 Changes **3 files changed** (+163 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `launcher/src/backend.rs` (+149 -14) 📝 `launcher/src/cli.rs` (+1 -1) 📝 `launcher/src/main.rs` (+13 -8) </details> ### 📄 Description ## What changed **The bug.** When the launcher's binary had been replaced under the running process (an update from `horizon-launcher update`, another launcher window, or an earlier update in the same run), the next self-update failed with "No such file or directory". Reproduced with a minimal program: after the running file is replaced, `std::env::current_exe()` on Linux returns `/path/horizon-launcher (deleted)` (it reads `/proc/self/exe`), and `self_replace::self_replace` resolves the target from it, so `metadata()` fails with ENOENT: ``` current_exe now: Ok("/tmp/selfreplace-repro/target/debug/repro (deleted)") self_replace: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" }) ``` **The fix (launcher/src/backend.rs).** - Unix (Linux and macOS): the new binary is copied beside the path the launcher started from (`exe_path()`, read once at start), made executable with the old file's mode, and renamed over it. It no longer asks the system where the running binary is. Windows keeps `self_replace`, which moves the locked running exe aside. - Before downloading, the binary now at that path is asked for its `--version` (no console window on Windows); when it already is that release or newer, the update counts as done and nothing is downloaded. - `restart()` execs the new binary with the same arguments on Unix (spawn + exit on Windows) and returns an error message instead of exiting silently when it cannot start; the window shows it. **The message.** Settings: "Updated to X. Restart the launcher to use it." with the Restart button; sidebar: "Launcher updated to X" / "Restart the launcher"; CLI: "Launcher: updated to X. Restart the launcher to use it." ## How tested - Unit tests: `--version` output parsing (and a binary that is not a launcher gives no version); `replace_binary` puts the new file at the path after another update swapped it, and when the file is gone, executable, with no temp file left. - End to end on Linux with the real `backend::self_update` and `restart`, a local HTTP server serving a `horizon-launcher-linux-x86_64.tar.gz` "release" (a small script), from a throwaway program linked to the launcher library: - plain update: `self_update: Ok(())`, the file is the new one, restart execs it with the same arguments; - file swapped first (`current_exe` = `… (deleted)`, the failing case): `Ok(())`, replaced, restarted; - file already updated to 0.1.9 by someone else, no server running: `Ok(())` without a download, restart runs it. - `cargo fmt --check`, `cargo clippy --all-targets -D warnings`, `cargo test` (launcher), `python tools/check_public_tree.py`. - Not run: macOS and Windows (only Linux per the project's rules; the macOS path is the Unix one, Windows keeps self_replace). No screenshot of the Ready state: it needs a release build and a newer launcher release on GitHub (0.1.4 is the newest). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:55:00 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2329
No description provided.