Skip to content

Daemon: child processes don't inherit merged env (breaks yt-dlp slides under launchd) #98

@heyalchang

Description

@heyalchang

Bug

Slide extraction fails under the daemon with:

Slides stream failed: yt-dlp exited with code 1:
ERROR: [youtube] ...: Requested format is not available

The same summarize --slides command works perfectly from the CLI.

Root cause

When the daemon runs under launchd, process.env.PATH is minimal (/usr/bin:/bin:/usr/sbin:/sbin). The daemon builds a merged env from the daemon.json snapshot and threads it through internal code — resolveExecutableInPath() correctly finds yt-dlp using the merged PATH. But spawnTracked() (packages/core/src/processes.ts:146) spawns child processes without passing env in the spawn options, so they inherit process.env (the minimal one).

This means yt-dlp can't find deno on PATH. Since yt-dlp 2025.11.12 (yt-dlp/yt-dlp#15012), deno is required for YouTube JS challenge solving. When cookies are enabled (--cookies-from-browser), yt-dlp uses authenticated YouTube APIs that require JS challenges — without deno, format resolution fails silently.

Reproduction

# Simulates the daemon's launchd environment:
env -i PATH="/usr/bin:/bin:/usr/sbin:/sbin" HOME=$HOME \
  /opt/homebrew/bin/yt-dlp --cookies-from-browser chrome \
  -f "bestvideo[height<=720][vcodec^=avc1][ext=mp4]/best[height<=720][vcodec^=avc1][ext=mp4]/bestvideo[height<=720][ext=mp4]/best[height<=720]" \
  "https://www.youtube.com/watch?v=ZNL5wwflU-E" --no-download
# → ERROR: Requested format is not available

# Same command with full PATH (includes /opt/homebrew/bin where deno lives):
yt-dlp --cookies-from-browser chrome \
  -f "bestvideo[height<=720][vcodec^=avc1][ext=mp4]/best[height<=720][vcodec^=avc1][ext=mp4]/bestvideo[height<=720][ext=mp4]/best[height<=720]" \
  "https://www.youtube.com/watch?v=ZNL5wwflU-E" --no-download
# → works fine

Environment

  • macOS 15 (Tahoe), arm64
  • summarize 0.11.1 (Homebrew)
  • yt-dlp 2026.2.4
  • deno 2.6.9 (at /opt/homebrew/bin/deno)
  • SUMMARIZE_YT_DLP_COOKIES_FROM_BROWSER=chrome set in daemon.json

Timeline

This is a latent issue that became visible through a combination of factors:

  1. The daemon was designed to build a merged env for internal use, but never applied it to process.env — this was fine initially since the daemon wasn't spawning external tools.
  2. Slides (d9ed602) introduced child process spawning (yt-dlp, ffmpeg). At that time yt-dlp didn't need deno, so the minimal PATH worked.
  3. Cookie support for slides (3011970) made yt-dlp use authenticated YouTube APIs.
  4. yt-dlp 2025.11.12 made deno required for JS challenges on authenticated APIs.
  5. The combination of cookies + deno requirement + minimal launchd PATH triggers the failure.

Fix

PR incoming — applies the snapshot env keys to process.env in src/daemon/cli.ts before starting the server, so child processes inherit the correct PATH.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions