FS#78611 - [composer] [2.5.5-1] Bash completion is not working

Attached to Project: Arch Linux
Opened by Fabien Schurter (fabschurt) - Friday, 26 May 2023, 09:05 GMT
Last edited by Pierre Schmitz (Pierre) - Sunday, 28 May 2023, 08:47 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Pierre Schmitz (Pierre)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Hi! I have the extra/composer package installed, and Bash completion is not working.

My environment:

* x86_64 Intel
* Manjaro Gnome
* Gnome Terminal
* core/bash 5.1.016-2
* core/bashrc-manjaro 5.1.016-2
* core/bash-completion 2.11-3
* extra/composer 2.5.5-1

How to reproduce: I start a fresh Bash session in my terminal, then I cd into a folder with a composer.json file in it (not mandatory I guess, but the safer, the better), and then I type composer<space><tab><tab><tab> but the command line doesn’t get completed like it should (thanks to the /usr/share/bash-completion/completions/composer file that the package installs on the system).

I think I know where the problem lies. The Bash completion script is generated by a built-in Symfony Console command (the `Symfony\Component\Console\Command\DumpCompletionCommand` class), that Composer exposes as its `composer completion` command. By default, this command takes the name of the called executable (as set by the invoking shell) as the name that will be used as the «target» of the completion, as can be seen here: https://github.com/symfony/symfony/blob/v6.2.10/src/Symfony/Component/Console/Command/DumpCompletionCommand.php#L94.

So, in the context of this Arch package’s PKGBUILD, the called executable is actually named `composer.phar` (as seen here: https://gitlab.archlinux.org/archlinux/packaging/packages/composer/-/blob/2.5.7-1/PKGBUILD#L27). The problem is that the `composer.phar` executable is then renamed to `composer` when it is installed on the system (as seen here: https://gitlab.archlinux.org/archlinux/packaging/packages/composer/-/blob/2.5.7-1/PKGBUILD#L51). The Bash completion script is then unable to do the proper matching, as it is expecting a command named `composer.phar` and not `composer`.

I think the problem MAY be solved by renaming `composer.phar` to `composer` BEFORE running `composer completion bash` in the PKGBUILD’s `build()` function, or maybe even as soon as in the `prepare()` function, just to be safe. (Obviously, this would mean replacing references to `composer.phar` with references to `composer` everywhere else in the file).
This task depends upon

Closed by  Pierre Schmitz (Pierre)
Sunday, 28 May 2023, 08:47 GMT
Reason for closing:  Fixed
Additional comments about closing:  Good catch! Fixed with 2.5.7-2

Loading...