From 11379d9eec629d77705b60547ab979f2eaba7e44 Mon Sep 17 00:00:00 2001 From: MicBur <164754856+MicBur@users.noreply.github.com> Date: Fri, 31 Jul 2026 08:03:23 +0200 Subject: [PATCH] fix(worker): remove POSIX assumptions that broke the Windows worker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Antigravity ran the WIN-DEV test (Task D) and reported the honest result: no `Compiling direct RPP job` in the log — the worker aborts on `tar -I zstd` and `/tmp/` paths. Confirmed in the code; three separate spots, all of which stop a Windows worker before it can run ANY dispatched job that needs a toolchain: - toolchain_manager.cpp: `tar -I zstd -xf` is GNU tar syntax. Windows 10/11 ship bsdtar (libarchive) as tar.exe, which rejects -I. bsdtar detects zstd from the stream, so plain `-xf` is correct there. Guarded by _WIN32; POSIX unchanged. - worker.cpp: the received toolchain archive was written to a hardcoded "/tmp/suco_tc_recv_...", which does not exist on Windows, so the transfer failed. Now uses std::filesystem::temp_directory_path(), falling back next to the cache dir if that cannot be determined. - config.cpp: the header-cache directory fell back to "/tmp/.cache/suco/headers" whenever HOME was unset — which is the normal case on Windows. Now tries LOCALAPPDATA/USERPROFILE there, then the platform temp dir. Linux behaviour is unchanged in all three (the POSIX branches are byte-for-byte the old code). Compiles clean on MinGW/Windows. This does not by itself make V3-on-a-Windows-worker work — it removes the blockers that stopped the test from getting that far. Task D stays open until the run shows `Compiling direct RPP job` on WIN-DEV. Co-Authored-By: Claude Opus 4.8 --- src/worker/config.cpp | 15 +++++++++++++-- src/worker/toolchain_manager.cpp | 8 ++++++++ src/worker/worker.cpp | 10 +++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/worker/config.cpp b/src/worker/config.cpp index 5018da7..d327777 100644 --- a/src/worker/config.cpp +++ b/src/worker/config.cpp @@ -1,6 +1,7 @@ #include "config.h" #include "protocol.h" #include +#include #include namespace suco::worker { @@ -61,11 +62,21 @@ Config Config::parse(int argc, char** argv) { if (hc_dir_env) { config.header_cache_dir = hc_dir_env; } else { + // HOME is normally unset on Windows (it uses USERPROFILE/LOCALAPPDATA), so the + // old "/tmp/..." fallback handed a Windows worker a path that cannot exist. + // Try the platform's own home variables, then the platform temp dir. const char* home = std::getenv("HOME"); - if (home) { +#ifdef _WIN32 + if (!home) home = std::getenv("LOCALAPPDATA"); + if (!home) home = std::getenv("USERPROFILE"); +#endif + if (home && *home) { config.header_cache_dir = std::string(home) + "/.cache/suco/headers"; } else { - config.header_cache_dir = "/tmp/.cache/suco/headers"; + std::error_code ec; + const std::filesystem::path tdir = std::filesystem::temp_directory_path(ec); + config.header_cache_dir = + (ec ? std::string(".") : tdir.generic_string()) + "/.cache/suco/headers"; } } diff --git a/src/worker/toolchain_manager.cpp b/src/worker/toolchain_manager.cpp index e0b8930..7048eb3 100644 --- a/src/worker/toolchain_manager.cpp +++ b/src/worker/toolchain_manager.cpp @@ -82,7 +82,15 @@ bool ToolchainManager::extract_toolchain(const std::string& hash, const std::str SUCO_LOG_INFO("Extracting toolchain {} from {}...", hash, archive_path); + // `-I zstd` is GNU tar syntax. Windows 10/11 ship **bsdtar** (libarchive) as + // tar.exe, which rejects -I outright — so a Windows worker failed every toolchain + // extraction and could never run a dispatched job at all. bsdtar detects zstd from + // the stream itself, so plain -xf is both sufficient and correct there. +#ifdef _WIN32 + std::string cmd = "tar -xf \"" + archive_path + "\" -C \"" + tmp_dir + "\""; +#else std::string cmd = "tar -I zstd -xf \"" + archive_path + "\" -C \"" + tmp_dir + "\""; +#endif std::string out_log; if (!run_cmd_simple(cmd, out_log)) { SUCO_LOG_ERROR("Failed to extract toolchain archive {}. Output: {}", archive_path, out_log); diff --git a/src/worker/worker.cpp b/src/worker/worker.cpp index 30cce8b..001c038 100644 --- a/src/worker/worker.cpp +++ b/src/worker/worker.cpp @@ -642,7 +642,15 @@ void Worker::run_worker_compile_loop() { std::error_code ec; std::filesystem::create_directories(std::filesystem::path(cache_dir).parent_path(), ec); - std::string temp_archive = "/tmp/suco_tc_recv_" + toolchain_hash + ".tar.zst"; + // Use the platform temp dir: "/tmp" does not exist on a + // Windows worker, so this write failed and the toolchain + // was never received. Fall back next to the cache dir if + // the temp dir cannot be determined. + std::error_code tec; + std::filesystem::path tdir = std::filesystem::temp_directory_path(tec); + if (tec) { tec.clear(); tdir = std::filesystem::path(cache_dir).parent_path(); } + std::string temp_archive = + (tdir / ("suco_tc_recv_" + toolchain_hash + ".tar.zst")).string(); if (suco::receive_file(download_sock, temp_archive)) { SUCO_LOG_INFO("Worker successfully received toolchain archive: {}", temp_archive); ToolchainManager::extract_toolchain(toolchain_hash, temp_archive);