Skip to content

fix(server): build the OpenAI server on Windows (MSVC)#28

Merged
mudler merged 1 commit into
masterfrom
fix/server-windows-build
Jun 17, 2026
Merged

fix(server): build the OpenAI server on Windows (MSVC)#28
mudler merged 1 commit into
masterfrom
fix/server-windows-build

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

The v0.3.0 release build failed on Windows: examples/server/model_fetch.cpp included POSIX-only <sys/wait.h>/<unistd.h> and used fork/execvp/waitpid, so MSVC errored with:

model_fetch.cpp(8): fatal error C1083: Cannot open include file: 'sys/wait.h'

(main.cpp and openai_format.cpp already compiled fine on MSVC; this was the only blocker.)

Fix

Make the model fetcher cross-platform:

  • Windows: run curl/wget via _spawnvp(_P_WAIT, ...) from <process.h>. Like the POSIX fork+execvp path, it launches the program directly with no shell, so the no-shell-injection property (URL/paths passed as literal argv entries) is preserved. Windows 10+ ships curl.exe.
  • have_tool uses where on Windows, command -v on POSIX.
  • POSIX behavior is unchanged (same fork/exec/waitpid under #else).

Test

  • Linux build (PARAKEET_BUILD_SERVER=ON) still compiles; test_server_resolve passes.
  • The Windows compile error is in the guarded include/exec path that this PR fixes.

model_fetch.cpp included POSIX-only <sys/wait.h>/<unistd.h> and used
fork/execvp/waitpid, so the Windows release build failed with
'Cannot open include file: sys/wait.h'. Add a Windows path using _spawnvp
(_P_WAIT), which runs curl/wget directly without a shell, keeping the
no-shell-injection property of the POSIX exec path. have_tool now uses
'where' on Windows and 'command -v' on POSIX.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mudler mudler merged commit 92a5f03 into master Jun 17, 2026
10 checks passed
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