Repository navigation
fix(rust): keep SystemRoot for Windows test and run processes - #425
Merged
Merged
Conversation
Rust test and run actions get a cleared environment with only HOME,
PATH, and Cargo variables. On Windows, Winsock cannot initialize without
SystemRoot, so any test that opens a socket fails with os error 10106
("The requested service provider could not be loaded or initialized").
Pass SystemRoot alongside PATH on Windows. It is fixed per host, like
the PATH Once already forwards there.
Amp-Thread-ID: https://ampcode.com/threads/T-01a1bf6d-95f0-76f7-9a26-c062fe0363e1
Co-authored-by: Marek Fort <marek@tuist.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
On Windows, processes Once starts from a Rust target's own build outputs now get
SystemRootalongsidePATH. These arerust_testruns (_rust_test_env) andonce run(_rust_binary_run_env)._rust_process_pathbecomes_rust_process_env, which returns both variables on Windows and the fixed systemPATHelsewhere, as before.Why
The tuist desktop Windows build on Once 0.77.4 now builds every crate, but 13 tests fail as soon as they open a socket (job):
Root cause
Rust test and run actions get a cleared environment:
HOME,PATH, and theCARGO_*runtime variables. Winsock (WSAStartup) needsSystemRootto load its service providers, so without it everyTcpListener::bindorTcpStream::connectfails with error 10106. Compile and build-script actions already getSystemRootthrough_rust_windows_tool_env, but_rust_cargo_runtime_envkeeps onlyCARGO_*keys for tests, and the processPATHhelper only forwardedPATH.Approach and alternatives
Forward exactly one more variable, read from the same Windows tool environment that compile actions already use. Like
PATH,SystemRootis fixed for a given host, so the action key stays stable. I didn't forward the whole Windows tool environment: compiler variables such asINCLUDE/LIBwould make test results depend on the installed toolchain without any runtime need. Users could setenv_inherit = ["SystemRoot"]on arust_testtarget, butcargo_workspacedoesn't pass it through to the tests it generates, and every Windows test that uses networking would need it.Impact
Windows Rust tests and
once runbinaries can use sockets. Windows test action keys change once. Linux and macOS environments are unchanged.Validation
processes_launched_from_rust_artifacts_keep_windows_system_root. On a simulated Windows host, both test and run environments containPATHandSystemRootbut notINCLUDE; on Linux they contain only the fixedPATH. It fails without the change (SystemRootmissing).cargo test -p once-frontend --test prelude rust(52 passed) and... cargo(44 passed).cargo clippy -p once-frontend --tests -- -D warningsandcargo fmt --all --checkare clean.I couldn't run Windows locally; Once's Windows CI and the tuist desktop Windows job on the next release are the end-to-end checks.