Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unsolicited messages output to stdout, --quiet does not do anything #1611

Closed
rdaysky opened this issue Nov 20, 2019 · 21 comments
Closed

Unsolicited messages output to stdout, --quiet does not do anything #1611

rdaysky opened this issue Nov 20, 2019 · 21 comments
Assignees
Labels
area/cli Related to the command line
Milestone

Comments

@rdaysky
Copy link

rdaysky commented Nov 20, 2019

  1. Install Poetry 0.12.17
  2. poetry config settings.virtualenvs.create false
  3. Try to run something using poetry run. Observe that a message “Skipping virtualenv creation, as specified in config file.” is output to stdout.
  4. Try poetry -q run, poetry run --quiet and other variations thereof. Observe that nothing is run and an exception is raised.

There should be a way to suppress all output other than that of the command being run. Otherwise it’s impossible to run scripts reliably.

@rdaysky rdaysky added the kind/bug Something isn't working as expected label Nov 20, 2019
@finswimmer finswimmer added area/cli Related to the command line and removed kind/bug Something isn't working as expected labels Nov 20, 2019
@finswimmer
Copy link
Member

Hello @rdaysky ,

I took a quick look at the code and it seems that those messages are all printed to stdout. A cleaner way would be, to print them to stderr, to not get in conflict with the programs output when redirecting to other programs.

Thanks for pointing to it!

fin swimmer

@rdaysky
Copy link
Author

rdaysky commented Nov 20, 2019

That would be an improvement for sure, but still the right thing to do is either to make -q actually work, suppressing all output, or, even better, not to output any such messages unless -v is present.

@finswimmer
Copy link
Member

Hello @rdaysky ,

I see. Could you please try the latest preview version? For me run e.g. poetry -q run pip list suppresses all kind of output.

I will have a look on how/if it is possible to suppress all info/debugging/... messages but still print the output of the running program.

fin swimmer

@sdispater sdispater self-assigned this Nov 21, 2019
@sdispater sdispater added this to the Future milestone Nov 21, 2019
@finswimmer
Copy link
Member

finswimmer commented Nov 21, 2019

Hello again,

I talked to @sdispater and this is something we definitely add to our agenda. But at the moments the priority are tasks that has to be done before launching poetry 1.0. So this issue will most likely not be handled before 1.1.

I hope you can have patience with us.

fin swimmer

@legel
Copy link

legel commented Mar 8, 2020

Greetings, this is indeed very annoying. There should absolutely be a flag for quickly setting verbosity to warnings / errors only. These logs are useless, I don't need to know that you've found the environment context file for the 100th time successfully. In general print statements should be avoided once functionality is stable, but otherwise at least give us the opportunity to shut them up.

@sfermigier
Copy link

I've been struggling with a similar issue (with Poetry 1.1.4) and I believe I have found several inconsistencies:

  • poetry -q install is quiet, but doesn't do anything (seemingly)
  • poetry install -q works, but is as verbose as poetry install
  • poetry -q update doesn't do anything (quietly)
  • poetry update -q works as expected, quietly
  • poetry --ansi <whatever> gives an error message. Same with --no-ansi or -v.

This is also inconsistent with the usage:

USAGE
  poetry [-h] [-q] [-v [<...>]] [-V] [--ansi] [--no-ansi] [-n] <command> [<arg1>] ... [<argN>]

Ideally, it shouldn't matter wether -q, -v, --ansi, etc. are before or after the command.

@dimaqq
Copy link
Contributor

dimaqq commented Dec 15, 2020

I guess the worst offender is:

poetry -q install no output, doesn't do anything, successful return value 😱

@dimaqq
Copy link
Contributor

dimaqq commented Dec 15, 2020

While there is some difference between poetry install -vv vs. poetry install -q, the latter is still very chatty.

I've run both under script on an open-source library aiodynamo, let's call it warm start (deps downloaded and cached; new venv every time):

  • poetry install -vv: 204KB of output
  • poetry install -q: 160KB of output

The diff shows that -vv adds bits like "skipped", "for following reason", "not required".
The baseline -q are realtime updates "Installing...", package names, completion.

IMO the situation is much worse for large packages (more deps, more permutations during concurrent install).
Also it's notably worse for cold boot (e.g. CI flow without cached downloads, where downloading NN% is displayed).

Maybe let's add a help-wanted label?

@camerondavison
Copy link

+1 tools should write to stderr. I have a python script that outputs json that I want to send through jq and cannot because it is outputting Skipping virtualenv creation, as specified in config file. when I run it in CI

seems like a good first step would be to make sure that everything that outputs as part of poetry run is stderr

@benriou
Copy link

benriou commented Sep 8, 2021

I would be interested on an update on this. :)

@metov
Copy link

metov commented Jan 27, 2022

I'll add my +1 here. This is clearly the sort of informational message that should be directed to standard error, not standard out, as a matter of general Unix software design best practices. However, given that poetry is not just any old program, but a Python package framework, this issue is doubly important: When poetry pollutes standard out with random warnings, it becomes very difficult to follow the unix philosophy in CLI programs.

@tedivm
Copy link

tedivm commented Feb 11, 2022

Since this has been on the agenda since 2019 is there any hope of it actually happening?

@dimbleby
Copy link
Contributor

@tedivm there's always hope, please submit an MR

Although funnily enough you might have got in just immediately after #5179 was merged, perhaps this is fixed already

@jjorissen52
Copy link

This one just bit us in a deployment. Something happened to break poetry install in a previously working GH Action (probably not poetry's fault), so I tried to move over to a requirements.txt based installation instead (poetry export --without-hashes --format=requirements.txt > requirements.txt) and saw this wonderful error message on the next attempted run:

ERROR: Invalid requirement: 'Skipping virtualenv creation, as specified in config file.' (from line 1 of requirements.txt)
Error: Process completed with exit code 1.

Naturally, you'd want to try poetry -q ... after that, but uhhh... well...

poetry export -q --without-hashes --format=requirements.txt | wc -l
# 0

poetry -q also appears to suppress the stdout of the actual command you were trying to use.

@dimbleby
Copy link
Contributor

dimbleby commented Sep 6, 2022

You are complaining about the exact opposite of what this issue describes which is "--quiet does not do anything".

(What were you expecting --quiet to do if not make the output quiet? No matter: that poetry export uses a virtual environment is fixed in master and meanwhile you can use -o requirements.txt instead of going via stdout)

This issue should be closed.

@jjorissen52
Copy link

jjorissen52 commented Sep 6, 2022

In my head, I was complaining about unexpected behavior surrounding what poetry puts to stdout. From the original issue:

There should be a way to suppress all output other than that of the command being run. Otherwise it’s impossible to run scripts reliably.

So I don't know if -q suppressing even the actual output of actually the intended command to be run would be considered the opposite of what this issue is for, but sure.

Notice also, the first half of the title is

Unsolicited messages output to stdout

Not sure if you saw the error message

ERROR: Invalid requirement: 'Skipping virtualenv creation, as specified in config file.' (from line 1 of requirements.txt)
Error: Process completed with exit code 1.

wherein poetry ouputs unsolicited messages to stdout

@neersighted
Copy link
Member

I think everyone is a bit turned around and frustrated here -- to recap, -q suppresses all output on stdout, which will include normal poetry export output (hey, a weird choice, but it's an opt-in and -o exists). This original issue has been solved and I will close it.

Issues with the export plugin are at https://github.com/python-poetry/poetry-plugin-export, though this is fixed in master and the next version of that plugin. In the mean time, you can simply use poetry export -o requirements.txt and read from that requirements.txt file -- there will be no erroneous output there.

The Skipping virtualenv creation message (and virtual environment messaging) in general should likely be written to stderr, but that is another issue entirely.

@jjorissen52
Copy link

@neersighted Thank you.

@rdaysky
Copy link
Author

rdaysky commented Sep 6, 2022

@neersighted The original issue was about Poetry outputting unsolicited messages to stdout when invoking poetry run. Does this no longer happen?

@neersighted
Copy link
Member

They should now be on stderr -- if any were overlooked, please open a new issue with a reproduction/specifics.

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area/cli Related to the command line
Projects
None yet
Development

No branches or pull requests