When trying to install the module (latest dev version 8.x-1.0-beta10+13-dev), I'm getting a php fatal error:

PHP Fatal error: Trait 'Drupal\Console\Command\Shared\CommandTrait' not found in /project/modules/contrib/metatag/src/Command/GenerateTagCommand.php on line 33

For it to work, i have to remove all these services in metatag.services.yml

  • metatag.generate_tag
  • metatag.generate_group
  • metatag.tag_generator
  • metatag.group_generator

I do not have drupalconsole installed

Anyone has an idea why is not installing correctly ?

Comments

j.b created an issue. See original summary.

j.b’s picture

Issue summary: View changes
csedax90’s picture

Same error, but I've Drupal console installed

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new3.12 KB

Darnit :-( Does this help?

damienmckenna’s picture

Out of interest, what version of Drupal core and PHP are you using?

dan2k3k4’s picture

Getting the above error with beta10 but not beta9. And Drupal Core 8.1.x (whatever was latest 8.1 release) with PHP 7.0.0

j.b’s picture

Patch not working with latest Dev Release.
PHP Fatal error: Trait 'Drupal\\metatag\\Command\\Drupal\\Console\\Command\\Shared\\CommandTrait' not found

Drupal : 8.2.0
PHP: 5.6.23

j.b’s picture

Hi Guys,

I managed to solve this problem.

I had to Install Drupal Console in my Drupal project folder.

Just run this command in your Drupal site folder:

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

Metatag is now working correctly (i'm using latest dev version)

G42’s picture

I get a similar error:

PHP Fatal error:  Class 'Drupal\Console\Command\GeneratorCommand' not found in /var/www/cascade/dev/d8-city/htdocs/modules/contrib/metatag/src/Command/GenerateGroupCommand.php on line 27
damienmckenna’s picture

The problem is that we shouldn't need to install Drupal Console in order for Metatag to work :-\

dawehner’s picture

StatusFileSize
new867 bytes

For now I think the right approach would be to just include the services using a ServiceProvider and checking that console exists.
Note: This patch is purely for myself's composer.json file.

Status: Needs review » Needs work

The last submitted patch, 11: 2810835-11.patch, failed testing.

dkre’s picture

I'm seeing the same error after updating from beta10 - beta11.

The patch (#4) didn't help unfortunately.

PHP: 5.6.21-5+donate.sury.org~trusty+1
Drupal 8.2.2

platinum1’s picture

Same problem on 8.3.0-dev and PHP 7.0.12

Running @j.b's solution in #8 resulted in:

Fatal error: Cannot use Symfony\Component\Console\Command\Command as Command because the name is already in use in /home/solution/public_html/my-domain.com/vendor/drupal/console-core/src/Command/CompleteCommand.php on line 12

sachbearbeiter’s picture

Drupal 8.2.2
PHP 7
Metatag 8.x-1.0-beta11
No Drupal console installed (and i don't want it ;)

Can confirm the problem ...

damienmckenna’s picture

Status: Needs work » Postponed (maintainer needs more info)

Is the problem fixed by updating to the latest release of Console?

jeroent’s picture

Status: Postponed (maintainer needs more info) » Active

I can also confirm the problem.

Drupal 8.2.3
PHP 7
Metatag 8.x-1.0-beta11
No Drupal Console installed.

grm34’s picture

Same here,

Drupal 8.2.3
PHP 7.0.13 (Fast-CGI)
Metatag 8.x-1.0-beta11
No Drupal Console installed.

PHP Fatal error:  Trait 'Drupal\Console\Command\Shared\CommandTrait' not found in /var/www/clients/client1/web1/cms-dev/modules/metatag/src/Command/GenerateTagCommand.php on line 33
Drush command terminated abnormally due to an unrecoverable error.                                           [error]
Error: Trait 'Drupal\Console\Command\Shared\CommandTrait' not found in
/var/www/clients/client1/web1/cms-dev/modules/metatag/src/Command/GenerateTagCommand.php, line 33
didier misson’s picture

Hello
Does the last Metatag version solve this problem ?
Does the patch #4 solve this problem ?

Near 2 months. But I know it's not a simple problem.
What is the recommande action to unlock ?

Thanks ;-)
Didier

grm34’s picture

Hi Didier,

No, the dev metatag version does not solve the problem.

No, the patch in #4 does not solve the problem too.

Maybe deactivate metatag until this issue will be solved.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new2.15 KB

Does this patch solve the problem? It's an update of dawehner's patch in #11 above.

grm34’s picture

Status: Needs review » Active

Thank you DamienMcKenna !

Solved for me with metatag-n2810835-21.patch in #21 with latest metatag dev version.

didier misson’s picture

Thank you Damien
I will test this patch probably tomorrow

damienmckenna’s picture

Status: Active » Needs review

"Needs review" is the appropriate issue status when there's a patch being reviewed.

platinum1’s picture

The patch works for me, but I would like to see some additional feedback before changing the status from "Needs review".

mudassar774’s picture

StatusFileSize
new2.47 KB

Non of the above patch works for me. The issue remains when I try to run any Drupal console command with `metatag-beta11`. I made one patch which works for me.

jmolivas’s picture

I did download a new drupal vanilla and metatag 8.x-1.0-beta11+6-dev no DrupalConsole downloaded on the site and can not replicate this error.

jmolivas’s picture

@mudassar774 you must be using an old version of DrupalConsole

As a note starting on RC releases DrupalConsole must be installed per site
https://github.com/hechoendrupal/DrupalConsole/#download-as-new-dependency

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

You can still install the Launcher
https://github.com/hechoendrupal/DrupalConsole/#install-drupal-console-l...

curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal
Christopher Riley’s picture

After installing console (although nice, I think it adds even more complexity to a site so please consider not requiring it), when I go to activate the module from the modules page I get the following:

Fatal error: Trait 'Drupal\Console\Command\Shared\CommandTrait' not found in /home/sitename/staging/public_html/modules/metatag/src/Command/GenerateTagCommand.php on line 33

running drupal about I see:

-> drupal about

Drupal Console (1.0.0-rc10)
===========================

Suggestions on what to do besides go back to Drupal 7?

dkre’s picture

#29, I haven't tried the lastest couple of patches but this issue is in the latest release only. Try beta10. I've been using beta10 for a couple of months without issue.

Re: D7 - Metatag doesn't support views atm. If I knew this prior to starting development I would have switched back to D7.

Christopher Riley’s picture

I am heading back to Drupal 7. It is no wonder that Drupal 8 is taking forever to get implemented on major sites. I guess I will go back to seeing about getting things running with Drupal 8 as soon as Acquia feels that they can update their main site to it.

Thanks for the info.

damienmckenna’s picture

I'm sorry I haven't gotten to this yet, have been trying to clear other things off my todo list before focusing on Metatag-D8.

Agreed on #26 not being the correct solution with the latest DrupalConsole, the namespace is "Drupal\Console\Command\Shared".

damienmckenna’s picture

So here are two questions for anyone having problems:

  • Have you updated to the latest Console release?
  • Do you also have Drush installed, and if so, is it the latest 8.x release?
Christopher Riley’s picture

My answer is yes to both to your last set of questions. I will install another dev site on my server so that I can try various things as time permits however I have a couple of projects that I need to get moving on and I can't justify to myself or the customers to go with D8 because there are too many modules that are still "iffy" or "of concern" because they are trying to use Console like this one is.

dkre’s picture

I don't think this uses Console, it's just a namespace clash (?) which I'm surprised hasn't popped up more.

For the record - D8 is young but it is great in so many ways. While we discovered a few deficits during planning the end result is a pretty solid platform.

damienmckenna’s picture

@Christopher Riley: We'll have this finished soon, don't let it stop you building sites with D8.

Also, DrupalConsole rc11 is out.

mudassar774’s picture

@Christopher Riley: Try drupal_console:rc11 and metatag:beta11 both works fine together -:) without any patch

jmolivas’s picture

@mudassar774 Can you try uninstalling Drupal Console from your site

composer remove drupal/console

And check if the error appears?

mudassar774’s picture

@jmolivas I can confirm no error with
drupal:8.2.4
metatag:beta11
drush:8.1.0 (i installed with ui also)

jmolivas’s picture

@mudassar774: Awesome thanks

For me this issue is does not look related to not having DrupalConsole installed on the site.

Looks more related to having an old version of DrupalConsole on the site.

Feel free to ping me if any question related to DrupalConsole or a follow-up on this issue.

Christopher Riley’s picture

Alright I blew away everything and installed a fresh version of D8 then the latest console then metatag b11 and viola things actually are working. Thanks everyone for the assist now let's hope that everything else goes as smooth.

damienmckenna’s picture

Status: Needs review » Closed (works as designed)

So the lesson-learned is - keep up-to-date on Drush and DrupalConsole. I'm sorry that people had problems with this, hopefully things will be better going forwards.

didier misson’s picture

Damien,
Thanks for all this work about Metatag.
It's a great module for us.
;-)
Didier

spideep’s picture

#28 solve it. Thanks @jmolivas

Chris Gillis’s picture

Upgrading from 8.x-1.0-beta11 to 8.x-1.0-beta12 fixed it for me.

jagundez’s picture

I updated drupal/console to "drupal/console": "~1.0" and the metatag module "drupal/metatag": "^1.0", to the stable version but there is an other problem:

PHP Fatal error:  Cannot use Drupal\Console\Core\Bootstrap\DrupalConsoleCore as DrupalConsoleCore because the name is already in use in /meso/vendor/drupal/console/src/Bootstrap/Drupal.php on line 11

Fatal error: Cannot use Drupal\Console\Core\Bootstrap\DrupalConsoleCore as DrupalConsoleCore because the name is already in use in /meso/vendor/drupal/console/src/Bootstrap/Drupal.php on line 11

Any suggestion?

Thanks!

aronne’s picture

StatusFileSize
new3.99 KB

Using drupal/console:^0.11.3 the above patches cannot be applied, so I've done this one which seems to work.

kamalMaroc’s picture

@aronne but this version of drupal console 0.11.3 does not working fine with last version of drupal core like 8.3.2

try to run this command in root folder of your projet : drupal list
of course you not get all commande line of drupal console.

So to fixe that try to remove drupal console of your site with this command line composer remove drupal/console and keep drupal console 0.11.3 globaly on your machine.

And it works 100%.