Skip to content

fix(windows): use correct yt-dlp config path and resolve .CMD shims i… - #468

Closed
my1057739543-max wants to merge 1 commit into
Panniantong:mainfrom
my1057739543-max:fix/windows-yt-dlp-and-subprocess
Closed

fix(windows): use correct yt-dlp config path and resolve .CMD shims i…#468
my1057739543-max wants to merge 1 commit into
Panniantong:mainfrom
my1057739543-max:fix/windows-yt-dlp-and-subprocess

Conversation

@my1057739543-max

Copy link
Copy Markdown
  1. yt-dlp config written to wrong path. _install_system_deps writes --js-runtimes node to
    ~/.config/yt-dlp/config (a Linux path). On Windows yt-dlp reads %APPDATA%/yt-dlp/config, so the config is never
    applied. Result: install prints " yt-dlp configured" but doctor reports YouTube as [!] 未配置 JS runtime
    they contradict because doctor already uses the cross-platform get_ytdlp_config_path() helper while install
    hardcodes the Linux path.

  2. mcporter install fails with WinError 2. _install_mcporter calls subprocess.run(["npm", ...]) with a bare
    command name. On Windows npm/mcporter/npx are .CMD shims, and CreateProcess does not append PATHEXT, so this
    raises FileNotFoundError (WinError 2) even though shutil.which("npm") finds it.

Fix

Both reuse patterns that already exist elsewhere in the codebase:

  1. Call the existing agent_reach.utils.paths.get_ytdlp_config_path() instead of hardcoding ~/.config/yt-dlp — the
    same helper doctor/youtube.py already use.

  2. Resolve command names via shutil.which() before subprocess.run(), mirroring probe.py:probe_command() and the
    existing undici install path (npm_cmd = shutil.which("npm")).

Verification

Tested on Windows 11 with Anaconda Python 3.11.7 + venv install:

  • After fix, install writes --js-runtimes node to %APPDATA%/yt-dlp/config (verified the file is created there
    and ~/.config/yt-dlp/config is no longer touched).
  • doctor now reports YouTube 视频和字幕 — 可提取视频信息和字幕 (install and doctor agree).
  • subprocess.run([shutil.which("npm"), "--version"]) succeeds (returns 11.13.0); the bare ["npm", ...] form
    raises FileNotFoundError: WinError 2. Same for mcporter.

Change scope: 1 file changed, 28 insertions(+), 8 deletions(-)agent_reach/cli.py only.

Notes

  • Did not touch the _install_system_deps Windows branch for gh (separate issue — gh CLI auto-install has no
    Windows path, only linux/darwin). Happy to send a follow-up PR if welcome.

…n subprocess

Two Windows-install bugs in cli.py:

1. yt-dlp JS runtime config was written to ~/.config/yt-dlp/config
   (Linux path). On Windows yt-dlp reads %APPDATA%/yt-dlp/config, so
   install reported 'configured' while doctor (which already uses the
   cross-platform get_ytdlp_config_path helper) reported it unconfigured.
   Reuse the existing helper so install and doctor agree.

2. _install_mcporter called subprocess.run(['npm', ...]) / ['mcporter']
   with bare command names. On Windows these are .CMD shims and
   CreateProcess does not append PATHEXT, so subprocess raised
   FileNotFoundError (WinError 2). Resolve via shutil.which first
   (mirrors probe_command and the existing undici install path).

Verified on Windows 11: install now writes %APPDATA%/yt-dlp/config,
doctor reports YouTube as configured, and npm/mcporter subprocess calls
succeed instead of raising WinError 2.
@Panniantong

Copy link
Copy Markdown
Owner

感谢覆盖 Windows yt-dlp 路径和 CMD shim。merged #575#577 已分别完成 HOME-first 配置路径及解析后的 npm、mcporter CMD 调用,并有 Windows 回归测试,因此关闭。

@Panniantong Panniantong closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants