You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a problem in arduino-builder, I believe only in legacy code, but since all the relevant code lives in this repo, I thought to report this in this repository.
In some (debug) output lines of the Arduino builder, in machine-readable logger mode, paths are not properly escaped. This causes problems with spaces in the path, where the IDE shows e.g.
Using board 'uno' from platform in folder C:\Program
(I typed this error message from memory, since I did not have a broken setup to reproduce it at hand).
I think this is easy to reproduce by installing the IDE in a path with spaces (which is the default on Windows).
To show the problem by running arduino-builder manually, we need a hardware folder with spaces. E.g.:
fprintf(w, "===%s ||| %s ||| %s\n", level, format, a)
}
I guess this is to encode strings, but leave floats and integers unchanged? Or are there other types that do their own encoding? I'm not too familiar with this code, or the machine-readable logger interface.
A fix that works is to simply use InstallDir.String(), forcing these paths to be a string. This approach is not ideal, since it is easy to forget the String (though if this code is to be removed soon, that might be ok). The code should be checked for similar cases, though.
An alternative would be to fix this in the logger, perhaps by checking all arguments to see if they implement the Stringer interface (i.e. have a String() method) and if so, call that and encode the resulting string (I guess this is also what Fprintf does with Stringer types, except for the encoding). Unless there are types that need to do their own encoding, but I doubt that (would also be bad design, really).
The text was updated successfully, but these errors were encountered:
This is a problem in
arduino-builder
, I believe only in legacy code, but since all the relevant code lives in this repo, I thought to report this in this repository.In some (debug) output lines of the Arduino builder, in machine-readable logger mode, paths are not properly escaped. This causes problems with spaces in the path, where the IDE shows e.g.
(I typed this error message from memory, since I did not have a broken setup to reproduce it at hand).
I think this is easy to reproduce by installing the IDE in a path with spaces (which is the default on Windows).
To show the problem by running
arduino-builder
manually, we need a hardware folder with spaces. E.g.:Then, you can run
arduino-builder
against that. e.g. comparearduino-builder
1.4.4:And current master:
As you can see, the path was encoded originally, but no longer since the arduino-cli inception happened.
The reason is that the path printed changed from a string:
https://github.com/arduino/arduino-builder/blob/cb100d0e47f68cba82430f376157d860d79c1d83/target_board_resolver.go#L104-L105
https://github.com/arduino/arduino-builder/blob/cb100d0e47f68cba82430f376157d860d79c1d83/types/types.go#L140
To a
paths.Path
object:arduino-cli/legacy/builder/target_board_resolver.go
Lines 60 to 61 in 7663d7e
arduino-cli/arduino/cores/cores.go
Line 51 in 7663d7e
However, the machine logger only treats strings specially by encoding them, and passes all values as-is to
fmt.Fprintf()
:arduino-cli/legacy/builder/i18n/i18n.go
Lines 223 to 232 in 7663d7e
I guess this is to encode strings, but leave floats and integers unchanged? Or are there other types that do their own encoding? I'm not too familiar with this code, or the machine-readable logger interface.
A fix that works is to simply use
InstallDir.String()
, forcing these paths to be a string. This approach is not ideal, since it is easy to forget the String (though if this code is to be removed soon, that might be ok). The code should be checked for similar cases, though.An alternative would be to fix this in the logger, perhaps by checking all arguments to see if they implement the
Stringer
interface (i.e. have aString()
method) and if so, call that and encode the resulting string (I guess this is also what Fprintf does withStringer
types, except for the encoding). Unless there are types that need to do their own encoding, but I doubt that (would also be bad design, really).The text was updated successfully, but these errors were encountered: