How to redirect arduino-cli errors to file

Hello, I have a game in which the user can write arduino code and compile. Thus, we are using arduino-cli to compile by sendind a compile command to cmd. However, we need to use Boost library to hide the cmd black screen.

Here's the command we send:
arduino-cli compile -b arduino:avr:uno "CODE_PATH" --output-dir "CODE_OUTPUT_PATH" 2>&1

And we use the following lines to execute the command:

boost::process::child cmdProcess(CommandAsChar, boost::process::std_err> OutputPath, boost::process::windows::hide);
cmdProcess.wait();

As you can see, I'm executing a child process that send the compile command to cmd.
However, I was unable to capture the error log from codes. For instance, if someone misses a semicolon on the code, the output file does not contain the error message. What I acctually get is something like this on the file that is on "OutputPath":


panic: nil passed instead of *os.File to NewColorable()

goroutine 1 [running]:
github.com/mattn/go-colorable.NewColorable(0xde34d8)
	/go/pkg/mod/github.com/mattn/go-colorable@v0.1.8/colorable_windows.go:104 +0x1c5
github.com/mattn/go-colorable.NewColorableStdout(...)
	/go/pkg/mod/github.com/mattn/go-colorable@v0.1.8/colorable_windows.go:122
github.com/fatih/color.init()
	/go/pkg/mod/github.com/fatih/color@v1.7.0/color.go:25 +0xa6

I also tried changing "std_err" to "std_out" but no lucky. How can I capture the error messages using this logic? The errors are not streamed to std_err?

Thanks in advance!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.