hechoendrupal / drupal-console

The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
http://drupalconsole.com
GNU General Public License v2.0
939 stars 559 forks source link

Global drupal console install type error in PHP7 #2515

Open twhiston opened 8 years ago

twhiston commented 8 years ago

If I have a globally installed version of drupal console and am running PHP 7.0.8-4+deb.sury.org~trusty+1 I see the errors

TypeError: Argument 1 passed to Drupal\Console\Command\Command::__construct() must be an instance of Symfony\Component\Console\Helper\HelperSet, none given in /var/www/vagrant/vendor/drupal/console/src/Command/Command.php on line 35
TypeError: Argument 1 passed to Drupal\Console\Command\Command::__construct() must be an instance of Symfony\Component\Console\Helper\HelperSet, none given in Drupal\Console\Command\Command->__construct() (line 35 of /var/www/vagrant/vendor/drupal/console/src/Command/Command.php).

However if i have a version of drupal console installed in my project, and use that instead commands all run correctly

jmolivas commented 8 years ago

@twhiston are you using DrupalComposer based project?

twhiston commented 8 years ago

not directly, but it is our own composer based setup so its similar

Saphyel commented 8 years ago

I'm using php7 & I installed it via git clone and no errors

jmolivas commented 8 years ago

@twhiston This is not related to php7 is related to have two diff version of DC what is the version loaded on the site? since using the composer template

twhiston commented 8 years ago

I think you may be right, as the composer version is @stable, but the global version was at 1.0.0-beta3. I'll test it again with both at the newest beta4 and see what happens

joshmiller83 commented 8 years ago

I'm getting this error when I try to run drush ... is console and drush not compatible?

Edit: I'm using composer based build that brings in the latest stable of console (beta5) and have drush 8.1.3 ... php7

verasativa commented 8 years ago

I have same version on project and system (1.0.0-beta5), php7 and composer. Same error :/

scotteuser commented 8 years ago

Same issue here with: "Drupal Console" version "1.0.0-beta5" and Drush Version : 8.1.3 with the following in composer.json:

"drush/drush": "~8.0",
"drupal/console": "~1.0",
scotteuser commented 8 years ago

First error was able to get past by:

  1. using global drupal console only (removing from composer.json)
  2. and having only drush in the composer json

That led to a new similar error with metatag which I was able to get it working by applying this patch to metatag (assuming you use that project):

"drupal/metatag": {
  "Fix drush drupal console compatability error": "https://www.drupal.org/files/issues/metatag-deactivate_drupalconsole_services_0.patch"
}

Patch applied using: "cweagans/composer-patches": "~1.0"

Seems like a bit of a workaround and goes against the recommendation to have both drush and drupal console in the composer.json, but allowed me to continue with module generation, config deployment, etc.

jameswilson commented 7 years ago

I'm still getting this issue where my global DrupalConsole version 1.0.0-beta5 is installed fresh today in ~/.console but my project (drupal-project, running the latest Drupal 8.2.2) installed version 1.0.0-rc8, but was installed exactly the same way:

$ composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

~/.console/composer.json:

{
    "minimum-stability": "dev",
    "require": {
        "drupal/console": "~1.0"
    }
}

How could it be that running the same command from two different folders could result in two different versions being installed?

Update 1: It seems that trying to require the specific latest version in my global install breaks due to some other requirement holding things back:

$ composer require drupal/console:1.0.0-rc8
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for drupal/console 1.0.0-rc8 -> satisfiable by drupal/console[1.0.0-rc8].
    - Conclusion: remove gabordemooij/redbean dev-master
    - Conclusion: don't install gabordemooij/redbean dev-master
    - drupal/console 1.0.0-rc8 requires gabordemooij/redbean ~4.3 -> satisfiable by gabordemooij/redbean[v4.3, v4.3.1, v4.3.2, v4.3.3].
    - Can only install one of: gabordemooij/redbean[v4.3, dev-master].
    - Can only install one of: gabordemooij/redbean[v4.3.1, dev-master].
    - Can only install one of: gabordemooij/redbean[v4.3.2, dev-master].
    - Can only install one of: gabordemooij/redbean[v4.3.3, dev-master].
    - Installation request for gabordemooij/redbean (locked at dev-master) -> satisfiable by gabordemooij/redbean[dev-master].

Update 2: Removing vendor and composer.lock from my global and reinstalling fixed the issues for me:

$ cd ~/.console
$ rm -rf vendor composer.lock
$ composer install
jmolivas commented 7 years ago

@jameswilson You should install DrupalConsole per site executing this composer command from your site root.

composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

If you want to have a global executable you can install the DrupalConsole Launcher using curl.

curl https://drupalconsole.com/installer -L -o drupal.phar

php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar

mv drupal.phar /usr/local/bin/drupal
jameswilson commented 7 years ago

@jmolivas thanks. Is there a way for console to somehow check for this kinds of condition where a global console is being run from one place but files from a different project-specific vendor folder load a different version, to give a more intelligent error warning message?

Warning: you're using Drupal Console version a.b.c installed in /path/to/global/drupal but this may with version x.y.z installed in /path/to/project/vendor/bin/drupal

Saphyel commented 7 years ago

Seems more sensible use priorities in this case local > global, anyway I encourage to stop using composer global, I hope this issue change your mind ... https://github.com/composer/composer/issues/5390