Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal Error: Duplicate key "module:download" detected at line 109 vendor/symfony/yaml/Parser.php #4273

Open
jameswilson opened this issue Oct 19, 2020 · 5 comments

Comments

@jameswilson
Copy link

Issue title

Duplicate key "module:download"

[ console ]

Problem/Motivation

Trying to use Drupal Donsole with Drupal 9, results in the following error w/ stack trace:

drupal generate:theme
PHP Fatal error:  Uncaught Symfony\Component\Yaml\Exception\ParseException: Duplicate key "module:download" detected at line 109 (near "  - modo"). in vendor/symfony/yaml/Parser.php:330
Stack trace:
#0 vendor/symfony/yaml/Parser.php(516): Symfony\Component\Yaml\Parser->doParse(Array, 0)
#1 vendor/symfony/yaml/Parser.php(312): Symfony\Component\Yaml\Parser->parseBlock(2, 'cache:rebuild:\n...', 0)
#2 vendor/symfony/yaml/Parser.php(516): Symfony\Component\Yaml\Parser->doParse('aliases:\n  cach...', 0)
#3 vendor/symfony/yaml/Parser.php(312): Symfony\Component\Yaml\Parser->parseBlock(1, 'aliases:\n  cach...', 0)
#4 vendor/symfony/yaml/Parser.php(95): Symfony\Component\Yaml\Parser->doParse('commands:\n  ali...', 0)
#5 /Users/jameswilson/App/Contrib/drupal- in vendor/symfony/yaml/Parser.php on line 330

Fatal error: Uncaught Symfony\Component\Yaml\Exception\ParseException: Duplicate key "module:download" detected at line 109 (near "  - modo"). in vendor/symfony/yaml/Parser.php:330
Stack trace:
#0 vendor/symfony/yaml/Parser.php(516): Symfony\Component\Yaml\Parser->doParse(Array, 0)
#1 vendor/symfony/yaml/Parser.php(312): Symfony\Component\Yaml\Parser->parseBlock(2, 'cache:rebuild:\n...', 0)
#2 vendor/symfony/yaml/Parser.php(516): Symfony\Component\Yaml\Parser->doParse('aliases:\n  cach...', 0)
#3 vendor/symfony/yaml/Parser.php(312): Symfony\Component\Yaml\Parser->parseBlock(1, 'aliases:\n  cach...', 0)
#4 vendor/symfony/yaml/Parser.php(95): Symfony\Component\Yaml\Parser->doParse('commands:\n  ali...', 0)
#5 /Users/jameswilson/App/Contrib/drupal- in vendor/symfony/yaml/Parser.php on line 330

Why fix this?

There are still valuable console commands that should be able to be run on Drupal 9.

How to reproduce

  1. Install Drupal 9 via composer recommended-project: composer create-project drupal/recommended-project my-project (currently, this installs to Drupal version 9.0.7)
  2. Add Drupal Console dependency to composer: cd my-project && composer require drupal/console (currently this adds console version dependency as `^1.9)
  3. Execute any drupal console command, eg vendor/bin/drupal generate:theme

Known workarounds

None.

@willtate
Copy link

willtate commented Dec 9, 2020

Seeing this as well.

  • Lando 3.0.21
  • Drupal 9.1
  • Drush 10.3.6
  • Drupal Console 1.9

@roborew
Copy link

roborew commented Feb 26, 2021

Big Sur
php 7.4
D8 and D9 project, happening in all.

Also experiencing this issue with the Conosle global package, outside of a the drupal directory. So appears unrelated to the version of drupal and more related to console and the parser.yml file at line:342:

if ($allowOverwrite || !isset($data[$key])) { $data[$key] = $value; } else { throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine); }

Debugging, the value module:download is already set in the $data array to 'mod' causing the error to be thrown when a new alias is trying to override module:download to 'modo'. The original download command is set in: vendor/drupal/console/src/Command/Module/DownloadCommand.php. But searching the code base I can't find where this additional 'module:download' Command is coming from. The only way around this at moment is to comment out line 345 in vendor/symfony/yaml/Parser.php:

// throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
Not an ideal fix but makes Drupal Console useable.

@jmuxfeldt
Copy link

jmuxfeldt commented Aug 1, 2021

I'm getting the same issue under Big Sur, Drupal 8 or 9, or just the console.phar outside a project. I also tried the bin in the vendor dir. I can confirm that commenting out line 355 of vendor/symfony/yaml/Parser.php works.

Exactly the same installation works fine under Ubuntu Linux Server 10. However, in both Linux and Big Sur, the console (version 1.9.7) is unbelievably slow. Takes 20 seconds to respond in linux, and over a minute under Big Sur (after patching under Big Sur). Something is seriously wrong.

Fatal error: Uncaught Symfony\Component\Yaml\Exception\ParseException: Duplicate key "module:download" detected at line 56 (near "module:download: modo"). in /Users/fuo/Sites/wwwroot/glyph.dr8.test/vendor/symfony/yaml/Parser.php:355
Stack trace:
#0 /Users/fuo/Sites/wwwroot/glyph.dr8.test/vendor/symfony/yaml/Parser.php(531): Symfony\Component\Yaml\Parser->doParse('modo', 0)
#1 /Users/fuo/Sites/wwwroot/glyph.dr8.test/vendor/symfony/yaml/Parser.php(327): Symfony\Component\Yaml\Parser->parseBlock(2, 'cache:rebuild: ...', 0)
#2 /Users/fuo/Sites/wwwroot/glyph.dr8.test/vendor/symfony/yaml/Parser.php(531): Symfony\Component\Yaml\Parser->doParse('aliases:\n cach...', 0)
#3 /Users/fuo/Sites/wwwroot/glyph.dr8.test/vendor/symfony/yaml/Parser.php(327): Symfony\Component\Yaml\Parser->parseBlock(1, 'aliases:\n cach...', 0)
#4 /Users/fuo/Sites/wwwroot/glyph.dr8.test/vendor/symfony/yaml/Parser.php(96): Symfony\Component\Yaml\Parser->doParse('commands:\n ali...', 0)
#5 /Users/fuo/Sites/wwwroot/glyph.dr8.test/vendor/symfony/yaml/Yaml.php in /Users/fuo/Sites/wwwroot/glyph.dr8.test/vendor/symfony/yaml/Parser.php on line 355

@jchatard
Copy link

jchatard commented Nov 16, 2021

Locate the file [project_directory]/console/aliases.yml* in your environment, open and remove one of the module:downloaddeclaration (I had two of them):

    module:download:
      - md
    ...
    module:download:  # I removed this line
      - modo          # and this one

You're good to go!

* [project_directory]: in my case is the directory which contains composer.json.

@awilhelm13
Copy link

For me this duplicated key was contained in $HOME/.console/aliases.yml, so you might also check this location

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants