devshop icon indicating copy to clipboard operation
devshop copied to clipboard

Platform verification fails if drush is installed via composer at project level

Open ericmaster opened this issue 8 years ago • 29 comments

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?

ericmaster avatar Oct 19 '18 06:10 ericmaster

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:

  1. Downgrade to drush 8.x in composer.json.
  2. Move drush to require-dev, and use --dev when running composer install locally. Currently provision does composer install without --dev

jonpugh avatar Oct 19 '18 13:10 jonpugh

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

image

So, drush is installed in devshop environment even though we added it as require-dev. Any way to control/remove that step without patching?

ericmaster avatar Oct 30 '18 17:10 ericmaster

@jonpugh running into this same problem. Can we control how composer is executed when webhooks are fired off?

philoSurfer avatar Dec 12 '18 07:12 philoSurfer

actually working through this a bit has created a Paradox.

  1. we need to explicitly manage Drush version in our composer for our development teams.
  2. 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. :)

philoSurfer avatar Dec 12 '18 07:12 philoSurfer

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.

jonpugh avatar Dec 12 '18 11:12 jonpugh

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 avatar Jan 21 '19 17:01 jienckebd

@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?

christianaldenjacobs avatar Feb 10 '19 00:02 christianaldenjacobs

This is an awesome quick fix... just triaging at the moment, I'll organize this into an epic soon.

jonpugh avatar Apr 13 '19 23:04 jonpugh

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.

jonpugh avatar Oct 14 '19 20:10 jonpugh

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!

stale[bot] avatar Mar 06 '20 15:03 stale[bot]

This issue is no longer marked for closure.

stale[bot] avatar Mar 17 '20 15:03 stale[bot]

This issue is no longer marked for closure.

stale[bot] avatar Mar 17 '20 15:03 stale[bot]

This issue is no longer marked for closure.

stale[bot] avatar Mar 17 '20 15:03 stale[bot]

This issue is no longer marked for closure.

stale[bot] avatar Mar 17 '20 15:03 stale[bot]

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!

stale[bot] avatar Jun 15 '20 16:06 stale[bot]

/unstale

SuperSandro2000 avatar Jun 15 '20 17:06 SuperSandro2000

This issue is no longer marked for closure.

stale[bot] avatar Jun 15 '20 17:06 stale[bot]

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!

stale[bot] avatar Sep 13 '20 19:09 stale[bot]

Bump

SuperSandro2000 avatar Sep 13 '20 20:09 SuperSandro2000

This issue is no longer marked for closure.

stale[bot] avatar Sep 13 '20 20:09 stale[bot]