Missing user feedback for why publish was aborted when --no-interaction is set
When trying to run poetry publish on one of our projects with --no-interaction set, we see that the build fails with the error Aborted! and no additional information about why.
It turns out that our build script runs poetry build prior to poetry publish --build. Because of this, we hit this condition in poetry: https://github.com/python-poetry/poetry/blob/2b16b2fcf15da2a69e118a637ab4ee4fcb6a234c/src/poetry/console/commands/publish.py#L60
When we remove --no-interaction we see the message There are 2 files ready for publishing. Build anyway? (yes/no) [no] as expected.
It would have been nice if this message had been visible in our CI system's logs in the first place. Instead of suppressing the user prompt completely, can we print the question and append something on the end to indicate that we're selecting the default option because we are running non-interactively? E.g.,:
There are 2 files ready for publishing. Build anyway? (yes/no) [no]
WARNING: --no-interaction is set. Choosing the default answer!
Aborted!
Alternatively, change the error message Aborted! to something more descriptive.
Additionally, when --no-interaction is unset, if our CI system encounters this situation, it hangs forever, and the prompt never shows up in the console logs, even after aborting the build. This is what prompted us to start using --no-interaction in the first place.
I also have this issue.
I would expect the --no-interaction to be equivalent to typing 'yes' at the user prompt. Obviously it doesn't make sense to not use the --no-interaction flag in a CI system; that's what it's for.
It's possible that a more explicit flag like -y, similar to how apt-get -y install works could be clearer than --no-interaction in this case.
For me, I solved this by removing the build files before running publish with the --build option. Assuming the default dist directory:
rm -rf dist/
poetry publish --build --no-interaction
While this works, I hope a future poetry release would either make --no-interaction be like typing yes at the prompt, or add a new -y flag.
+1 on this issue. Removing the dist/ dir certainly works, but it's pretty frustrating. It would be better to have an option to build only if build artifacts don't already exist.
It would also help if the --clean option that was added to the build command in Poetry v2.0 was also available for the publish command.
Then we could do poetry publish --clean --build in a single command.