composer-bin-plugin
composer-bin-plugin copied to clipboard
No-Dev installation fails when defined as dev dependency
(I hope someone has a better title)
The plugin is installed as a dev dependency (in "require-dev") and has "@composer bin all install" as a "post-install-cmd" setup. Installing no-dev ("composer install --no-dev") makes the installation fail with the error "Command 'bin' is not defined.". It would be great if the plugin would offer a solution to this e.g. by handling the post-install and post-update command itself.
As a developer I want to define several dev tools in multiple sub-directories so that I bypass possible version conflicts. With this the composer-bin-plugin has nothing to do with the production environment, so it is a dev dependency. Unfortunately the needed composer hooks makes it fail in such scenario.
Wrapping a custom bash script around this may help but that is not really a good solution.
Example:
{
"require-dev": {
"bamarni/composer-bin-plugin": "1.4.1"
},
"scripts": {
"post-install-cmd": [
"@composer bin all install --ansi"
]
}
}
# Composer version 2.2.4
composer install --no-dev
Notes:
- The plugin could handle the hooks itself when registering event handlers during the PluginInterface::activate method.
I am really not sure how do you expect the plugin to fix this? By doing composer install --no-dev
, since you installed it as a dev dependency, you are removing completely the plugin. So I have trouble to see or understand how the plugin could further interfere in the installation process to remove or handle a post install hook.
The only thing I could possible see is hook on the post install to remove the bin scripts, but I do not think it's a good solution:
- it's starting to meddle more with the user scripts and making assumptions on how the user scripts are written & configured
- it will still not work on a first install
A possible solution however is to leverage the forward-mode
instead of using scripts.
Closing for now, please feel free to comment or open a new issue if it's not clear or if you have further questions!