Platform verification fails if drush is installed via composer at project level
When drush is installed locally as part of the project, platform verification fails because the corresponding alias cannot be found. The command executed is:
/var/aegir/projects/[projectname]/dev/web/../vendor/bin//drush --backend=2 @platform_[project]_dev provision-verify 2>&1
The command could not be executed successfully (returned: [preflight] The alias @platform_[project]_dev could not be found. , code: 0)
I had to remove locally installed drush for it to pass, but I use locally installed drush in my local environment. Any ideas or workaround?
Hi Eric,
Aegir & Provision are explicitly not compatible with Drush 9 when included in the core composer.json file.
See https://www.drupal.org/project/provision/issues/2953349
Your options are:
- Downgrade to drush 8.x in composer.json.
- Move drush to require-dev, and use
--devwhen running composer install locally. Currently provision does composer install without--dev
Hi Jon,
Option 2. actually seemed to be a viable option for us but it seemed that the command run is comoser install instead of composer install --no-dev

So, drush is installed in devshop environment even though we added it as require-dev. Any way to control/remove that step without patching?
@jonpugh running into this same problem. Can we control how composer is executed when webhooks are fired off?
actually working through this a bit has created a Paradox.
- we need to explicitly manage Drush version in our composer for our development teams.
- moving drush to require-dev does nothing as @ericmaster stated, devshop is using composer install (not composer install --no-dev) which would be bad... because it would not include our behat dependencies
So i think the real solution is to get have the Aegir user explicitly call the Drush executable path it needs until Drush 9 is supported. (this is what we did at Acquia when we ran into all kinds of crazy problems with Drush 4, 5, 6, 7, 8. :)
My plan is to make composer_install_coomand a true context property so that each platform can store it's own.
I'll be up in a few hours and will show you what I mean.
I'm sure there are better solutions, but I added a hook to my composer build that swaps in a different symlink for vendor/bin/drush to point to an alternative executable in my code base that either calls global Drush or project Drush.
So added this to composer.json to set up the hooks:
"scripts": {
"post-install-cmd": [
"Acquia\\Blt\\Custom\\Composer\\Plugin::scaffold"
],
"post-update-cmd": [
"Acquia\\Blt\\Custom\\Composer\\Plugin::scaffold"
]
},
Content of that hook:
<?php
namespace Acquia\Blt\Custom\Composer;
/**
* Composer plugin for handling drupal scaffold.
*/
class Plugin {
/**
* Runs when packages installed or updated.
*
* @param mixed $event
* The event.
*/
public static function scaffold($event) {
$platform_root = dirname(dirname(dirname(__DIR__)));
$project_drush_path = "{$platform_root}/sys/bin/drush";
$vendor_drush_path = "{$platform_root}/vendor/bin/drush";
if (file_exists($vendor_drush_path)) {
unlink($vendor_drush_path);
}
symlink($project_drush_path, $vendor_drush_path);
}
}
And then ./sys/bin/drush does this:
#!/usr/bin/env bash
current_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ -f /usr/local/bin/drush ]; then
/usr/local/bin/drush "$@"
else
"${current_path}/../../vendor/bin/drush" "$@"
fi
It's ugly, but I didn't want to remove Drush 9 / BLT from my project.
@jienckebd Your approach seems like it should work, but I'm receiving bash: warning: shell level (1000) too high, resetting to 1 and the drush call is hanging. Any ideas?
This is an awesome quick fix... just triaging at the moment, I'll organize this into an epic soon.
Hmm... For "Global Drush" we are now using drush8 required via composer in the devshop CLI.
The /usr/share/devshop/bin path contains drush and is set to be in the path.
The fix above would have to change /usr/local/bin/drush to /usr/share/devshop/bin/drush.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
This issue is no longer marked for closure.
This issue is no longer marked for closure.
This issue is no longer marked for closure.
This issue is no longer marked for closure.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
/unstale
This issue is no longer marked for closure.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Bump
This issue is no longer marked for closure.