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
I just updated to conan 2.2.1 which only contains the first PR. After this update I got error messages when building several recipes and spent a long time trying to understand and find the cause. The error message was print() got multiple values for keyword argument 'file' and the stacktrace pointed to a simple print call in my recipe.
Up to this point there is an error message that is difficult to understand, but at least there is a concrete error.
The second PR, however, would have meant that I would not get any errors at all, but the result of my recipes would no longer be correct.
Let me explain. In many recipes some files have to be saved (extracted licenses, CMake, etc.). Sometimes the code looks like this:
withopen(target_file) asf:
print(content, file=f)
In conan 2.2.1 this code leads to the error message mentioned above. As I said, difficult to understand and not nice.
But in the upcoming conan version, this does not lead to any error message at all. Instead, the content that should actually be written to the file is output to stderr and the file remains empty.
How to reproduce it
No response
The text was updated successfully, but these errors were encountered:
There was indeed some changes in latest Conan release, to avoid print() in recipes to mess with the stdout, because it was breaking all json outputs when recipes decide to add some print() statements.
This usage of print() was never documented or supported (to be fair, it is not explicitly forbidden in the docs), and the recommendation is to use save(self, target_file, content) as documented in https://docs.conan.io/2/reference/tools/files/basic.html#conan-tools-files-save, and in the same way we never documented or used print() in recipes, but instead the self.output is recommended.
The main reason for this is that very often it is necessary to have control and access to certain operations, to apply configuration or other behaviors, and this is only possible if these things are done in recipes via the Conan built-in utilities like save() or self.output.
In any case, I think we can fix it to make it not breaking, thanks very much for your report again.
If this is difficult to workaround for your case, we can try to do a Conan 2.2.2 release instead of having to wait until 2.3.
#17507 adds a new --output-file to enforce writing the result in that file irrespective of the stdout redirections or other possible issues. It will be in next Conan 2.12. Thanks for the feedback!
Describe the bug
In PR print to stderr the python's builtin
print
function was replaced and slightly refactored in Fix: remove existing 'file' arg when overwriting print.I just updated to conan 2.2.1 which only contains the first PR. After this update I got error messages when building several recipes and spent a long time trying to understand and find the cause. The error message was
print() got multiple values for keyword argument 'file'
and the stacktrace pointed to a simple print call in my recipe.Up to this point there is an error message that is difficult to understand, but at least there is a concrete error.
The second PR, however, would have meant that I would not get any errors at all, but the result of my recipes would no longer be correct.
Let me explain. In many recipes some files have to be saved (extracted licenses, CMake, etc.). Sometimes the code looks like this:
In conan 2.2.1 this code leads to the error message mentioned above. As I said, difficult to understand and not nice.
But in the upcoming conan version, this does not lead to any error message at all. Instead, the content that should actually be written to the file is output to
stderr
and the file remains empty.How to reproduce it
No response
The text was updated successfully, but these errors were encountered: