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
If a package manifest emits output to file description 1 (stdout) – using print(), for example) – then the parsing of the manifest can fail with the single-word error message "malformed".
This seems to be the localizable description of a JSON parsing error that's thrown when the input is malformed. It happens if the amount of standard output overflows the stdio buffer, or if the output is unbuffered for other reasons.
This is seen both in SwiftPM 5.3 and in the master branch as of at least d196d9d.
The reason this works sometimes is that if the amount of emitted text is small enough, the buffer is never flushed before libPackageDescription emits the resulting JSON to stdout (without going through buffered I/O, so it bypasses the buffered data and never flushes the buffer).
The compiled package manifest is passed a -fileno parameter, but it is currently always passed 1, which is stdout. The solution here is probably to open a new file descriptor for the JSON data and pass that to the compiled package manifest.
In addition to this, we should probable improve the error message that's shown if malformed JSON data does make it to SwiftPM itself.
The text was updated successfully, but these errors were encountered:
Additional Detail from JIRA
md5: 6efdf37ed86878a69d530a7eb03b1734
Issue Description:
If a package manifest emits output to file description 1 (stdout) – using
print()
, for example) – then the parsing of the manifest can fail with the single-word error message "malformed".This seems to be the localizable description of a JSON parsing error that's thrown when the input is malformed. It happens if the amount of standard output overflows the stdio buffer, or if the output is unbuffered for other reasons.
This example manifest illustrates the problem:
This is seen both in SwiftPM 5.3 and in the master branch as of at least d196d9d.
The reason this works sometimes is that if the amount of emitted text is small enough, the buffer is never flushed before libPackageDescription emits the resulting JSON to stdout (without going through buffered I/O, so it bypasses the buffered data and never flushes the buffer).
The compiled package manifest is passed a
-fileno
parameter, but it is currently always passed 1, which is stdout. The solution here is probably to open a new file descriptor for the JSON data and pass that to the compiled package manifest.In addition to this, we should probable improve the error message that's shown if malformed JSON data does make it to SwiftPM itself.
The text was updated successfully, but these errors were encountered: