-
Notifications
You must be signed in to change notification settings - Fork 68
[native_assets] Process.start hangs when executed in build method on Windows. #2077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It works for One thing that's different in the hooks is that they only get a subset of the environment variables (See the discussion on #32 about why we've chosen to hide most of the environment variables from the hooks.) |
I can confirm it's the problem of environment variables. In my computer, the {
"COMSPEC": "C:\\WINDOWS\\SYSTEM32\\cmd.exe",
"PATH": XXX,
"PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC",
"PROGRAMDATA": "C:\\ProgramData",
"PROMPT": "$P$G",
"SYSTEMROOT": "C:\\WINDOWS",
"TEMP": "C:\\Users\\rainy\\AppData\\Local\\Temp",
"TMP": "C:\\Users\\rainy\\AppData\\Local\\Temp"
} with some debugging, I found that appending final Map<String, String> env = Map.from(Platform.environment);
env["WINDIR"] = r"C:\WINDOWS";
final result = await runProcess(
executable: cm!.uri,
arguments: [
"-S",
sourceDir.toFilePath(),
"-B",
dstDir.toFilePath(),
],
logger: logger,
environment: env,
);
assert(result.exitCode == 0); May I ask why |
Did #1764 get reverted somehow? I do not see _filteredEnvironment in main but I see it here
|
Adding WINDIR does seem to prevent the freeze, but I think we are going to run into a mess of compile issues if the toolchain defaults are not used. CMake Error at CMakeLists.txt:37 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:37 (project):
No CMAKE_CXX_COMPILER could be found. Map.from(Platform.environment); is missing many environment variables for me on Windows so we cannot pass that. Map<String, String> env = Map.from(Platform.environment);
env["WINDIR"] = r"C:\WINDOWS";
for (var key in env.keys) {
stderr.writeln('$key: ${env[key]}');
}
final toolchain = String.fromEnvironment("CMAKE_TOOLCHAIN_FILE"); I don't think there's a way for us to get the CMAKE_TOOLCHAIN_FILE env variable. |
Oh, i forgot to attach it, too late last night. Try to also add 'SYSTEMDRIVE' with value of 'C:' and it will find c compiler in my condition. |
I am not sure why but it seems some variables are necessary for cmake, for the exact reasons, we need to dig into the source code of cmake. So, what's the solution? Adding the above 2 vars to allowed list seems to work, however, what if more variables are required in the future by other building systems or languages? Personally i think it's inflexible to hide most environment variables and there is no way to get them when called by native assets, it's also break the consistency of Platform.environment. Maybe we can use another variable like |
Seems like a great suggestion, maybe runProcess should become runBuildProcess and required in build hooks? This could solve the problem of piping logs from child processes as well as the environment variable issue here. |
Please make a PR to
Agreed that this is not ideal. Because opening up later would be non-breaking, while closing down later would be breaking, is why we decided to limit the environment variables for to start with. We can restart this conversation later on #32, once we have a longer list of environment variables that are needed for different use cases, and discuss a way on how to get access to them. |
I have submitted a PR, thanks for your suggestions 😄
Agree, the current solution is acceptable. |
Reproduction:
git clone https://github.com/google/dawn.git
Now in a isolate directory,
The process will not get stuck and will complete.
Any ideas why Process.start would work differently in the native_assets build hook on Windows?
The text was updated successfully, but these errors were encountered: