-
Notifications
You must be signed in to change notification settings - Fork 989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] Documentation for 'Packages lists' has misleading/incorrect instructions. #15826
Comments
It seems that there is something there that is broken in the setup. Conan outputs the json to The possible causes:
This definitely shouldn't be necessary. It would be great to know how to reproduce it locally. If I understand correctly, this only happens locally in Windows + git bash? Any specific git-bash version/installation? |
Thank you for the additional information. I will work on creating a small reproduction repository in github/gitlab for you. I originally thought this might be related to #15824, because I was essentially calling However, my initial test with this was the same result. I will work on this further tomorrow and update when I learn more. Thank you. |
Problem Restatement
Further InvestigationI've had other problems with git-bash. Such as "The conan auth command locks up the CLI on Windows git-bash mingw64" #15722 which is ultimately caused by a defect in python "getpass hangs on Windows in Ming64 git-bash shell" (python/cpython#115798) I have a work around in place to avoid the lockup aliasing the conan command alias conan='winpty -Xallow-non-tty conan.exe' THIS IS NOT A PROBLEM IF I REMOVE THIS ALIAS! Root CauseThis was a combination of two issue.
SuggestionCould you please add a Limitations section to the documentation that identifies git-bash as not compatible due to: python/cpython#115798. As a user I can either add the alias so interactive password entry works, or remove the alias which allows the conan redirection logic to work correctly. P.S. I'm not really happy with the fact that conan uses As always, thank you for your patience and help. |
The truth is that we didn't invent this pattern, and it is at the very least controversial, see for example https://stackoverflow.com/questions/4919093/should-i-log-messages-to-stderr-or-stdout/4919110, or https://www.reddit.com/r/golang/comments/jqvaft/why_does_the_log_package_always_output_to_stderr/ many users assume that "logging" output should go to In Conan this is the case for example, there are many operations like
Yes, this is a good idea to add to the knowledge base.
I am checking that some of the errors in the redirection in git base in the images above look like |
Which conan commands support piped operations? What you're describe is appropriate for command sequences like: conan command1 args ... | conan command2 args But if conan doesn't read from stdin, and always uses a parameter to identify the file for input such as Regardless, this is a conan implementation detail that greatly surprised me and some colleagues I discussed this with. (Although, to be fair, most of us graduated from the same University)
$ winpty --help
Usage: winpty [options] [--] program [args]
Options:
-h, --help Show this help message
--mouse Enable terminal mouse input
--showkey Dump STDIN escape sequences
--version Show the winpty version number This is obviously not a complete listing because the alias I use has other parameters such as alias conan='winpty -Xallow-non-tty conan.exe' The github repository for winpty doesn't have any documentation for usage or command line parameters that I could easily find, and a google search isn't helping with this 💢 I tried variations $ winpty NO_COLOR=1 -Xallow-non-tty conan.exe
winpty: error: cannot start 'NO_COLOR=1': Not found in PATH The following executed, but it gives the same results as before, specifically stderr is being combined with stdout. Moreover, it still had the trailing escape codes NO_COLOR=1 winpty -Xallow-non-tty conan.exe I found it!I took a look at the winpty source code from github, and found additional parameters that don't appear in help: -Xallow-non-tty
-Xconerr
-Xplain
-Xcolor I also found a winpty issue that provides additional information "Document the undocumented -X switches rprichard/winpty#103 If I use winpty -Xallow-non-tty -Xplain conan.exe create appA --format=json > jrr.json A little lower in the thread I referenced above seems to explain additional aspects of this problem
However, dropping $ winpty conan.exe create appA --format=json > jrr2.json
stdout is not a tty So -Xallow-non-tty and -Xplain would be needed together except for the fact that stdout and stderr are clubed into winpty's stdout. Summary:
|
Not necessarily for piping to Conan commands, but to other commands, for example I do this in my WSL ls $(conan cache path zlib/1.3)
Migration: Successfully updated settings.yml
conandata.yml conanfile.py conanmanifest.txt Note how the or something like conan list "*" | code - There are some users that the We are aware that some tools might check
|
Following up on this @RochaStratovan Did the above clarified the uses that explained the piping? I'd also like to understand when else could be done from the Conan side. |
Hello @memsharded, I understand they reason your team used piping as they did and how you use stderr. I and my team disagree with the that direction, but we also understand that this is the eco system that has evolved for conan, and we understand the reasoning, we just don't agree with it. But, meh, it is what it is. The FYI, python issue python/cpython#115798 exists for this, and they've politely explained that git-bash isn't high on their support list. What can conan do? I think we've discussed adding a section that explains known issues with git-bash. Maybe this documentation set can add an explanation that conan commands print logs as stderr and the dependency output as stdout which allows piping to work, and if the user's environment does any sort of output redirection this can cause issues? Thank you for your patience. Cheers! |
Environment details
Steps to reproduce
The Packages lists documentation at https://docs.conan.io/2/tutorial/other_features.html#packages-lists provides a command sequence that doesn't work.
The listed commands are as follows:
The problem is with the very first command.
conan create .
displays a lot of information, adding the --format=json option merely appends the build information to the end in a json format.The complete command takes all the normal output from
conan create
combined with the extra json output and places that into a build.json file.This is not a valid json file. It's prefixed by all the general output from
conan create .
.The normal
conan create
output could be suppressed by using the-vquite
option, but that assumes the underlying build (in our case CMake) doesn't display any messages along the way when it's compiling.Additionally I found that the file generated from the '>' output had a bunch of extra entries at the end of each line such as
^[[0k
. This was inserted by the git-bash shell I have running. A total shocker to me. I don't see the strange line endings on ubuntu linux, I see different line endings when I run the command from Windows CMD terminalgit-lab line endings
windows CMD line endings
It might be more portable for this command to write the build list information to a file rather than have it captured from standard output. This way it's in the format you want and only includes the list information.
Logs
No response
The text was updated successfully, but these errors were encountered: