fix: install Yarn Berry via mise HTTP client instead of curl/wget - #5
fix: install Yarn Berry via mise HTTP client instead of curl/wget#5doraemonkeys wants to merge 3 commits into
Conversation
The Yarn 2+ post-install path downloaded yarn.js by shelling out to curl/wget through os.execute. On Windows this is unreliable: under mise's sanitized os.execute environment curl/wget are not guaranteed to be on PATH, and stderr was redirected to NUL, so every failure collapsed into a misleading "Failed to download Yarn v2+". Use mise's built-in http.download_file (its own client, with retry) and build paths with file.join_path so the separator is correct on Windows. The bin directory is still created with mkdir (a shell built-in, no PATH dependency), so this works with currently released mise without any core changes. Fixes the Windows Yarn 2+ install failure reported in jdx/mise#10561
There was a problem hiding this comment.
Code Review
This pull request refactors the post-installation hook in hooks/post_install.lua to use the built-in file and http modules instead of shelling out to external tools like curl or wget. It also improves path handling by using file.join_path and quoting paths in shell commands. Feedback highlights that http.download_file returns an error string rather than raising an exception, meaning the current pcall wrapper will silently ignore download failures. Additionally, it is suggested to check if the bin directory already exists using file.exists before executing the mkdir command.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
- Handle both http.download_file failure conventions (raised error and returned error value) so a failed download is never silently ignored. - Skip mkdir when bin/ already exists to avoid a spurious error on re-install.
http.download_file is an async host function; invoking it through pcall fails with 'attempt to yield across a metamethod/C-call boundary'. Call it directly and check the returned err (nil on success), matching the convention used by vfox's own tests.
Fixes the Windows Yarn 2+ install failure reported in jdx/mise#10561.
Problem
mise use -g yarn@4fails on Windows withFailed to download Yarn v2+. The PostInstall hook downloadsyarn.jsby shelling out tocurl/wgetviaos.execute, which is unreliable: mise sanitizes theos.executeenvironment so neither is guaranteed to be onPATH, and stderr is redirected toNULso the real error is lost.Fix
yarn.jswith the built-inhttp.download_file(mise's own HTTP client, with retry) and check the returnederr. It must be called directly — it is an async host function, and wrapping it inpcallfails withattempt to yield across a metamethod/C-call boundary.file.join_pathso separators are correct on Windows, and quote paths passed tomkdir/chmod.No mise core change is required;
bin/is still created via shell built-inmkdir, so this works with released mise.Verified
Windows 11, mise 2026.7.1, plugin loaded via
mise plugins link:Notes for maintainers
crates/vfox/embedded-plugins/vfox-yarn/, so after merging, the embedded copy needs a sync + mise release before users see the fix.post_install.lua(both rewrite the Berry download path). This PR is a small fix for a current failure, so it probably makes sense to merge first and let feat: support yarn 6+ #4 rebase — its new v6+ path downloads via the same curl/wget shell-out and should switch tohttp.download_fileas well.