fix(daemon): propagate snapshot env to process.env for child processes#99
Open
heyalchang wants to merge 1 commit intosteipete:mainfrom
Open
fix(daemon): propagate snapshot env to process.env for child processes#99heyalchang wants to merge 1 commit intosteipete:mainfrom
heyalchang wants to merge 1 commit intosteipete:mainfrom
Conversation
Under launchd/systemd the daemon's process.env has a minimal PATH (e.g. /usr/bin:/bin:/usr/sbin:/sbin). The merged env built from daemon.json is threaded through internal code but never applied to process.env, so child processes spawned via spawnTracked() inherit the minimal environment. This became a real problem with yt-dlp 2025.11.12+ which requires deno (or another JS runtime) for YouTube JS challenge solving. When cookies are enabled, yt-dlp uses authenticated YouTube APIs that need JS challenges — but deno isn't on the minimal PATH, causing silent format resolution failures: ERROR: Requested format is not available The fix applies the whitelisted snapshot keys (PATH, API keys, tool paths) from daemon.json to process.env before starting the server, so all child processes inherit the correct environment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
process.envso child processes (yt-dlp, ffmpeg, deno, tesseract) inherit the correct PATH under launchd/systemdFixes #98
Problem
Under launchd,
process.env.PATHis/usr/bin:/bin:/usr/sbin:/sbin. The daemon's merged env is used internally to find binaries, butspawnTracked()spawns child processes without passing env — so they inherit the minimal PATH.This breaks yt-dlp 2025.11.12+ which needs
denofor YouTube JS challenges when cookies are enabled, causing "Requested format is not available" on slide extraction.Change
In
src/daemon/cli.ts, after building the merged env, iterate the whitelisted snapshot keys fromdaemon.jsonand apply them toprocess.env:Only the keys from
env-snapshot.ts(PATH, API keys, tool paths) are incfg.env— no arbitrary env vars leak through.Test plan
pnpm -s buildpassespnpm test— 272 passed, 0 failuressummarize daemon restart→ trigger slides from Chrome extension → verifyslides: donein daemon.log🤖 Generated with Claude Code