Open rainbow-alex opened 6 years ago
Running into this as well.
This is a classic "chicken and egg" problem. The second run is needed because composer-merge-plugin is not available to Composer until it has been installed. If the second installation run was not invoked by the plugin itself then no packages installed by composer-merge-plugin would be installed until a second manual run was made.
On the first pass, composer-merge-plugin as well as any dependencies specified directly in the project's composer.json
are installed by Composer. During it's installation, composer-merge-plugin registers to receive a PackageEvents::POST_PACKAGE_INSTALL
event callback from Composer itself when any package is installed. This callback (MergePlugin::onPostPackageInstall
) checks the event, and if it is determined to be the announcement of composer-merge-plugin itself being installed it will then set an internal flag specifying that this is the initial install of the plugin for the current deployment. A second callback is also registered for the ScriptEvents::POST_INSTALL_CMD
. This callback (MergePlugin::onPostInstallOrUpdate
) is the one which checks for the initial installation flag and if it is set triggers a second run of Composer. This second pass happens after composer-merge-plugin has been fully installed and registered in Composer's environment which then allows it to install packages which are only known to composer-merge-plugin.
Related: #145
When installing for the first time (from a lock file), the plugin triggers an additional install:
This doesn't seem necessary, at least not when you're installing from a lock. We'd like to avoid it because it also triggers the post install scripts twice...