Repository navigation
Replies: 1 comment 2 replies
|
Thanks for the detailed write-up. Taking the parts in turn: B ( A (PATH length): the problem is real, but we won't give each shim a PATH with only its own tool. Separately, #14392 turns on the identity install layout for Windows users with C (Explorer): mise doesn't write to the registry PATH that Explorer hands to apps, so I'd need a reproduction showing mise making that longer. D: agreed, one shared directory breaks for the same reason as B. AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5-5; version: 2.1.295. |
Uh oh!
There was an error while loading. Please reload this page.
Context & Appreciation
First and foremost, I want to express my appreciation to Jeff and everyone contributing to
mise. The project has fundamentally streamlined toolchain management, and I have transitioned away from ecosystems like WinGet almost entirely tomise.Between WinGet's stale package manifests, slow PR review cycles, lack of archive extraction support beyond standard
.zipfiles, and fragile handling of portable binaries,mise(especially paired with backends like Aqua) provides a much faster and more reliable model for consuming upstream releases directly.I recognize that maintaining platform-specific logic for Windows can be deeply frustrating—especially for maintainers whose primary workstations are Linux or macOS. Many of these headaches stem from decades of Microsoft's own technical debt and unaddressed legacy quirks in Win32 environment handling. Ideally, these platform limitations would be solved and funded upstream by Microsoft. Realistically, that will not happen anytime soon. Having spent substantial time diagnosing low-level Win32 loader behavior, process creation paths, and environment limits, I wanted to document these failure modes and outline a concrete, maintainable solution. I am more than happy to help contribute and test the Rust PRs necessary to land this.
This is Part 1 of a broader set of Windows ergonomics proposals. It focuses specifically on eliminating
%PATH%variable length exhaustion and process spawning failures, while fixing the way curated binaries resolve their companion assets.1. The Core Problems on Windows
A. The 8,191-Character
cmd.exeBoundaryAs documented in the
miseTroubleshooting Guide:Whenever a shim in
%LOCALAPPDATA%\mise\shims\is executed,mise-shim.exetriggersmise x/mise exec, which evaluatests.env_with_path_and_removals(). Today, this prepends thebin/directories of every globally and locally active tool directly into%PATH%.For developers using
miseas their primary package manager across multiple language runtimes, build systems, and CLI tools,%PATH%quickly exceeds 8,191 characters.While the Win32 API documentation for Environment Variables notes that Unicode environment blocks can reach up to 32,767 characters,
cmd.exehas an architectural limit of 8,191 characters for command strings and environment variable expansions. When an application runs in an environment where%PATH%exceeds 8,191 characters and attempts to spawn a subprocess viacmd.exe(e.g., executing.cmdor.batbatch wrappers likenpm.cmd, executing build scripts, or invoking subshells through Perl'ssystem()or Python'sos.system()using%COMSPEC%),cmd.exesilently discards%PATH%. Subprocesses fail immediately withcommand not founderrors.B. The
symlink_bins/ Shim Filtering Catch-22: Broken Runtime DiscoveryTo prevent exposing every internal executable bundled inside a tool's archive, backends like Aqua allow filtering which shims are generated (e.g., via the
filesarray). However, the current Windows implementation of this filtering breaks the OS loader.Consider
exiftool. The Windows archive contains a binary namedexiftool(-k).exealongside a critical dependency folder namedexiftool_files\. In an Aqua package manifest, mappingsrc: exiftool(-k).exetoname: exiftoolcorrectly creates theexiftoolshim—but it also exposes an unwantedexiftool(-k).exeshim into the global PATH.The two current workarounds both have fatal flaws:
settings.shims.exclude: While this prevents the shim generation, it is a global user setting. Forcing users to pollute their globalmisesettings array with obscure internal binary names (likeexiftool(-k)) for every edge-case tool they install is unscalable.symlink_bins = true: This isolates the filtered executable by placing a symlink inside a.mise-bins\folder and overridinglist_bin_paths()to point solely to that subdirectory. However, this introduces a fatal Win32 runtime error:.mise-bins\.GetModuleFileNameWto determine$0/ application root. When executed through.mise-bins\,GetModuleFileNameWreturns...\.mise-bins\exiftool.exe. The application then searches for...\.mise-bins\exiftool_files\, failing immediately because the asset folder is in the parent directory.C. Start Menu Truncation Breaking IDEs and Terminals (VS Code, Warp)
This environment bloat extends beyond background build scripts and actively degrades the primary developer experience in tools like Visual Studio Code and Warp Terminal.
When a user launches an application via the Windows Start Menu or Taskbar, the execution request is routed through
explorer.exe. Unlike direct process launchers (such as PowerToys Run, which bypasses this by spawning child processes directly with intact environments),explorer.exerelies on legacy shell extension handlers. It is notoriously fragile when constructing environment strings that exceed legacy registry buffer limits (often silently truncating variables that exceed ~2,048 or 4,096 characters).The result is massive user confusion: A developer opens VS Code or Warp from the Start Menu, opens the integrated terminal, and tries to run a command. Because
explorer.exesilently truncated the oversized%PATH%before launching the IDE, tools managed bymisethat fall late in the PATH are missing. Users assumemisefailed to inject paths, the terminal profile is misconfigured, or the IDE is broken, entirely unaware that Windows silently dropped half their PATH during the GUI launch.D. The WinGet "Just Use Symlinks" Pitfall
In the WinGet ecosystem, the maintainers attempted to address PATH bloat by symlinking binaries into a single directory (
%LOCALAPPDATA%\Microsoft\WinGet\Links). However, this introduced a critical flaw: standalone binaries that rely on sibling dependencies immediately broke for the exact sameGetModuleFileNameWreasons outlined above in Section B. WinGet had to introduce manifest hacks likeArchiveBinariesDependOnPathto force extraction folders back into the system%PATH%, ultimately recreating the exact same PATH overflow.2. Proposed Solution: Target-Scoped Shim Execution
misealready possesses the ideal architecture to solve this permanently: the shims directory (%LOCALAPPDATA%\mise\shims).Instead of eagerly concatenating all globally configured tools into
%PATH%on every invocation,miseshould construct a target-scoped environment for child processes, while treating.mise-binsstrictly as an indexing filter rather than an execution target.Key Mechanisms of this Architecture
%PATH%Bloat:By only prepending the target tool's own canonical directory (and any paths explicitly declared in user
[env]config), the child process's%PATH%remains compact (typically well under 1,000 characters), leaving thousands of characters of headroom before hitting the 8,191-charactercmd.exelimit orexplorer.exetruncation limits.If
tool-ainternally callstool-b(e.g.,npmcallingnode, or a script callinggit), Windows resolvestool-bvia Step 6 of the Dynamic-Link Library and Executable Search Order, which searches%PATH%.Because
%LOCALAPPDATA%\mise\shimsis permanently on%PATH%, Windows findstool-b.exein the shims directory. Whentool-bexecutes, its own shim constructs its own scoped environment cleanly. There is no need fortool-ato inherittool-b's raw install path upfront.symlink_bins):.mise-bins\(and backendfilesarray logic) should be used strictly as a Shim Filter Index duringmise reshimto determine which shims get created, preventing the need for globalshims.excludehacks. During execution,misemust resolve the target to its canonical path.Executing the canonical binary directly ensures that:
SetDllDirectoryWor global%PATH%pollution.GetModuleFileNameW(such as ExifTool looking forexiftool_files/or Electron looking forresources/) resolve to their real, physical folder naturally.Many desktop and Electron-based tools distribute standalone portable archives. Because this scoped shim approach prevents
%PATH%pollution and maintains canonical working directories,misecan comfortably manage hundreds of portable CLI and GUI tools without degrading system stability or triggeringexplorer.exeenvironment limits.3. Relevant Win32 APIs & Technical Documentation
For reference during implementation, the relevant platform behaviors are documented by Microsoft here:
cmd.exe8,191 chars)CreateProcessW32,767 Unicode char limit)CreateProcessWAPI ReferenceGetModuleFileNameWAPI ReferenceAll reactions