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);