Skip to content

Commit e0737cb

Browse files
fix(dev): add Windows compatibility for mintlify subprocess (#1902)
## Overview Fixes Windows compatibility issue where the `docs dev` command fails with `FileNotFoundError` when attempting to start the Mintlify development server. The issue occurs because Windows npm packages are installed as `.CMD` files which cannot be executed directly by `asyncio.create_subprocess_exec`. ## Type of change **Type:** Fix bug ## Additional notes **Problem:** When I was trying to run my local dev environment on Windows 11, the `docs dev` command failed with: ``` FileNotFoundError: [WinError 2] The system cannot find the file specified ``` After digging into the issue, I discovered that the script was attempting to run Mintlify as if it were a regular shell executable. On Windows, however, npm installs global packages like Mintlify as `.CMD` batch files rather than native executables. Because of this, `asyncio.create_subprocess_exec` cannot directly execute .cmd batch files on Windows because they require a shell (cmd.exe) to interpret them. To address this, the solution was to adjust how subprocesses are created based on the operating system. On Windows, `create_subprocess_shell` is used so the shell can properly interpret and run the `.CMD` file. On Unix-based systems (Linux and macOS), `create_subprocess_exec` is still used, since there is no need for invoking a shell. Platform detection is handled via `sys.platform == "win32"`, which ensures the behavior is correct and consistent across environments. The fix works for my machine running Windows 11 using Python 3.13 and Git Bash (MINGW64). The Mintlify development server starts successfully, file watching and hot reloading work as expected. --------- Co-authored-by: Lauren Hirata Singh <[email protected]>
1 parent 5e2c094 commit e0737cb

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

pipeline/commands/dev.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,27 @@ async def dev_command(
9696

9797
# Start mint dev in background
9898
logger.info("Starting mint dev...")
99-
mint_process = await asyncio.create_subprocess_exec(
100-
"mint",
101-
"dev",
102-
"--port",
103-
"3000",
104-
cwd=build_dir,
105-
stdout=asyncio.subprocess.PIPE,
106-
stderr=asyncio.subprocess.PIPE,
107-
)
99+
100+
# Use shell on Windows for .CMD compatibility, keep exec on Unix
101+
if sys.platform == "win32":
102+
# Windows requires shell for .CMD files
103+
mint_process = await asyncio.create_subprocess_shell(
104+
"mint dev --port 3000",
105+
cwd=build_dir,
106+
stdout=asyncio.subprocess.PIPE,
107+
stderr=asyncio.subprocess.PIPE,
108+
)
109+
else:
110+
# Unix systems can use exec directly
111+
mint_process = await asyncio.create_subprocess_exec(
112+
"mint",
113+
"dev",
114+
"--port",
115+
"3000",
116+
cwd=build_dir,
117+
stdout=asyncio.subprocess.PIPE,
118+
stderr=asyncio.subprocess.PIPE,
119+
)
108120

109121
# Start log forwarding tasks
110122
stdout_task = asyncio.create_task(_forward_logs(mint_process.stdout, "mint-stdout"))

0 commit comments

Comments
 (0)