FAKE
FAKE copied to clipboard
races in console trace while running Shell.Exec
Description
While running commands with Shell.Exec, output from stdout or stderr gets wrong.
Repro steps
- Step A
Prepare a bash script
err.sh:
>&2 echo err1 # writes to stderr
>&1 echo out1 # writes to stdout
>&2 echo err2
>&1 echo out2
sleep 1
- Step B
Use
Shell.Execto execute the bash script. I executed the script multiple times here to make the problem more obvious.
Shell.Exec("bash", "scripts/err.sh") |> ignore
Shell.Exec("bash", "scripts/err.sh") |> ignore
Shell.Exec("bash", "scripts/err.sh") |> ignore
Expected behavior
Output are colored accordingly. Lines are not messed up.
Actual behavior

Known workarounds
Please provide a description of any known workarounds.
Related information
- Operating system: Ubuntu 20.04
- .NET Runtime: 6.0
- Version of FAKE: latest
Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!
The root cause shold be:
- While running the command, callbacks are executed in different threads:
https://github.com/fsprojects/FAKE/blob/79aa1273d0311595bd404be5721d994301774552/src/app/Fake.Core.Process/Process.fs#L843-L850
Traceis not thread-safe, sinceConsoleTraceListeneris not thread-safe:
https://github.com/fsprojects/FAKE/blob/79aa1273d0311595bd404be5721d994301774552/src/app/Fake.Core.Trace/TraceListener.fs#L273-L308
Could we simply make ConsoleTraceListener thread-safe to fix this problem? If so, i could make a PR to fix this.
Thanks for reporting. Can you please use the create process API instead? Since the asyncShellExex is marked with an obsolete attribute. https://github.com/fsprojects/FAKE/blob/79aa1273d0311595bd404be5721d994301774552/src/app/Fake.Core.Process/Process.fs#L826-L829