-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
composer: always use --no-interaction option #2348
composer: always use --no-interaction option #2348
Conversation
a30e77a
to
4ffb4f7
Compare
Thanks for your contribution! Is Also, you need to add a changelog fragment. |
Hi, thanks for checking.
This did cross my mind and I haven't checked yet.
Wasn't aware. Will check both, maybe in the afternoon. Lots of deployments to do today. :) |
not using composer (anymore) |
So... In upstream composer, it looks like this is the commit where
It looks like |
FWIW I've found this PR from 2012: composer/composer#739 which is about |
Looks like it has been around since the beginning (initial release of composer was on March 1st, 2012) then. Good :) |
When looking at the code, it looks like it already specifies The only exception is the call where it determines the options available, there it passes Can you confirm that it hangs when run with |
Now that you mentioned it, I'm pretty sure that the command what was stuck was indeed |
I really wonder why it would hang (or wait for user input?) for |
It's definitely weird. I don't get it either. It didn't wait when I ran the same command interactively. When it was stuck it was just in S state. Anyway, I'll be back with details... |
4ffb4f7
to
59b30ba
Compare
First of all, here is a reproducer. playbook: ---
- hosts: gombuter
gather_facts: false
tasks:
- name: reproducer
composer:
working_dir: /opt/gomboser Expected behavior: it exits
Notably, the same problematic behavior can be reproduced without the ansible composer module. For example: ---
- hosts: gombuter
gather_facts: false
tasks:
- name: reproducer
command: 'php /usr/local/bin/composer help install --format=json'
register: result
- name: execution will never reach this task
debug:
var: result Thanks @flixfontein for pointing out that actually, With all this in mind, I've force-pushed a new version of the patch that takes all the above into account. Still there are the following points worth noting:
|
It definitely has to be addressed upstream. A tool should not hang when showing help. But if we can do something to help, we should definitely also do it :)
I guess this is something that could change in the future, so I think it's better to keep this. I think the current patch looks good, except that it needs a changelog fragment. |
10cadca
to
b05dd23
Compare
@@ -0,0 +1,2 @@ | |||
bugfixes: | |||
- composer - add no-interaction option when discovering available options to avoid an issue where composer hangs (https://github.com/ansible-collections/community.general/pull/2348). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- composer - add no-interaction option when discovering available options to avoid an issue where composer hangs (https://github.com/ansible-collections/community.general/pull/2348). | |
- composer - use ``no-interaction`` option when discovering available options to avoid an issue where composer hangs (https://github.com/ansible-collections/community.general/pull/2348). |
The composer module always uses the no-interaction option if it discovers it _after_ calling "composer help ..." but not on the help call itself. The lack of this option caused composer to not exit when called through the ansible module. The same example command when ran interactively does not prompt for user interaction and exits immediately. It is therefore currently unknown why the same command hangs when called through the ansible composer module or even directly with the command module. Example command which hangs: php /usr/local/bin/composer help install --format=json
b05dd23
to
f9e8f95
Compare
This raises yet another issue: Maybe we should also warn ansible users to not run composer as root, considering composer is almost certainly always being run as root in ansible. @felixfontein Do you still propose this behavior be changed upstream? |
I also confirm that while this reproducer hangs: ---
- hosts: gombuter
gather_facts: false
tasks:
- name: reproducer
composer:
working_dir: /opt/gomboser This completes succesfully: ---
- hosts: gombuter
gather_facts: false
tasks:
- name: reproducer
become: true
become_user: ubuntu
composer:
working_dir: /opt/gomboser The root warning prompt causes the hang. |
They seriously have an interactive warning?? Even on something like |
It seems like they seriously don't like users running it as root, even on something like |
Backport to stable-2: 💚 backport PR created✅ Backport PR branch: Backported as #2402 🤖 @patchback |
The composer module always uses the no-interaction option if it discovers it _after_ calling "composer help ..." but not on the help call itself. The lack of this option caused composer to not exit when called through the ansible module. The same example command when ran interactively does not prompt for user interaction and exits immediately. It is therefore currently unknown why the same command hangs when called through the ansible composer module or even directly with the command module. Example command which hangs: php /usr/local/bin/composer help install --format=json (cherry picked from commit eb455c6)
Backport to stable-3: 💚 backport PR created✅ Backport PR branch: Backported as #2403 🤖 @patchback |
@gangelop thanks for fixing this! |
The composer module always uses the no-interaction option if it discovers it _after_ calling "composer help ..." but not on the help call itself. The lack of this option caused composer to not exit when called through the ansible module. The same example command when ran interactively does not prompt for user interaction and exits immediately. It is therefore currently unknown why the same command hangs when called through the ansible composer module or even directly with the command module. Example command which hangs: php /usr/local/bin/composer help install --format=json (cherry picked from commit eb455c6)
…#2402) The composer module always uses the no-interaction option if it discovers it _after_ calling "composer help ..." but not on the help call itself. The lack of this option caused composer to not exit when called through the ansible module. The same example command when ran interactively does not prompt for user interaction and exits immediately. It is therefore currently unknown why the same command hangs when called through the ansible composer module or even directly with the command module. Example command which hangs: php /usr/local/bin/composer help install --format=json (cherry picked from commit eb455c6) Co-authored-by: George Angelopoulos <[email protected]>
…#2403) The composer module always uses the no-interaction option if it discovers it _after_ calling "composer help ..." but not on the help call itself. The lack of this option caused composer to not exit when called through the ansible module. The same example command when ran interactively does not prompt for user interaction and exits immediately. It is therefore currently unknown why the same command hangs when called through the ansible composer module or even directly with the command module. Example command which hangs: php /usr/local/bin/composer help install --format=json (cherry picked from commit eb455c6) Co-authored-by: George Angelopoulos <[email protected]>
SUMMARY
Since the composer command provides a no-interaction option, and since
we always call it non-interactively, we should always use it.
The lack of this option caused composer to not exit at least in one
instance when called as 'php /usr/local/bin/composer help install'.
The '-n' added with this patch resolved that issue.
ISSUE TYPE
As far as I can tell from the open issues, I'm the first one to report this.
COMPONENT NAME
ADDITIONAL INFORMATION
Versions and stuff.
On host:
On controller:
Output of composer showing the
-n
option: