youwee icon indicating copy to clipboard operation
youwee copied to clipboard

fix(services): complete PATH-first resolution for gallery-dl and yt-dlp

Open usrbinkat opened this issue 7 months ago • 1 comments

Depends on #59 and #60.

All pre-commit checks passing (biome, tsc, cargo check). Built, installed as .deb, and verified on Pop!_OS 24.04 with gallery-dl 1.32.0 installed via pipx install gallery-dl at ~/.local/bin/gallery-dl.


Problem

gallerydl.rs contains a get_system_binary_candidates() function with the same hardcoded-first path resolution ordering that #59 fixed in ffmpeg.rs, ytdlp.rs, and deno.rs. Hardcoded paths (/opt/homebrew/bin, /usr/local/bin, /usr/bin) are checked before $PATH entries, causing the app to miss gallery-dl binaries provided by Nix, Homebrew, pipx, or other package managers that express their binaries through PATH.

Additionally, gallery-dl and yt-dlp are commonly installed via pipx install gallery-dl and pipx install yt-dlp, which place binaries in ~/.local/bin. GUI applications launched from Linux desktop files or macOS Finder do not inherit the user's shell PATH modifications, so ~/.local/bin is never searched. The app reports "gallery-dl not found" even when the binary is installed and functional from the terminal.

The Settings > Dependencies page shows version and status for each dependency but does not display which binary path was resolved. When binary resolution produces unexpected results, users have no way to diagnose the issue without CLI access.

Solution

PATH-first resolution for gallery-dl (gallerydl.rs)

Apply the same PATH-first get_system_binary_candidates() pattern used in ffmpeg.rs, ytdlp.rs, and deno.rs:

  • Iterate $PATH entries first with deduplication
  • Append well-known fallback paths (~/.local/bin, /opt/homebrew/bin, /usr/local/bin, /usr/bin) for GUI environments that don't inherit shell PATH

~/.local/bin fallback for pipx-installed binaries (gallerydl.rs, ytdlp.rs)

Add ~/.local/bin as a well-known fallback path in gallerydl.rs and ytdlp.rs. This is the standard XDG user binary location used by pipx, pip install --user, and other Python packaging tools. Both gallery-dl and yt-dlp are PyPI packages commonly installed via pipx:

  • pipx install gallery-dl → ~/.local/bin/gallery-dl
  • pipx install yt-dlp → ~/.local/bin/yt-dlp

The ~/.local/bin fallback is not added to ffmpeg.rs (compiled C binary, never installed via pip) or deno.rs (has its own ~/.deno/bin/deno fallback already handled).

Resolved binary path display (DependenciesSection.tsx)

Display the resolved filesystem path for all four dependencies (yt-dlp, FFmpeg, Deno, gallery-dl) in Settings > Dependencies. Each dependency card shows the binary path in small monospace text below the status line when the binary is detected. The binary_path field is already returned by all four backend check commands — this change renders it in the UI.

Enables users and support to verify which binary the app resolved without requiring terminal access. Particularly useful for diagnosing cases where the wrong version is picked up or a stale binary at a hardcoded path shadows the intended one.

Nix devshell (flake.nix)

Add gallery-dl to the devshell packages list alongside yt-dlp, ffmpeg, deno, and glib-networking.

Test plan

  • [ ] gallery-dl installed via pipx install gallery-dl at ~/.local/bin/gallery-dl is detected by the app
  • [ ] Settings > Dependencies shows gallery-dl version and ~/.local/bin/gallery-dl path
  • [ ] Settings > Dependencies shows resolved binary path for all four dependencies (yt-dlp, FFmpeg, Deno, gallery-dl)
  • [ ] Binary paths are not displayed when a dependency is not installed
  • [ ] yt-dlp installed via pipx at ~/.local/bin/yt-dlp is detected by the app
  • [ ] nix develop provides gallery-dl on PATH
  • [ ] .deb builds, installs, and launches with gallery-dl resolved via PATH
  • [ ] macOS and Windows builds unaffected (fallback paths are additive, $HOME resolves correctly on all platforms)

usrbinkat avatar Apr 26 '26 21:04 usrbinkat

I've also fixed at least this part in the latest commits, thank you.

vanloctech avatar May 30 '26 15:05 vanloctech