composerize-drupal: Unable to geenrate composer file

Hei,

When I run the command, I simply get the error below and it deletes my core and some other files in my docroot:

PHP Fatal error:  Class 'Symfony\Component\Yaml\Yaml' not found in /Users/.../.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

Fatal error: Class 'Symfony\Component\Yaml\Yaml' not found in /Users/.../.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

I have tried setting symfony/yaml as required and re-updating the composerize project to no avail.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21

Most upvoted comments

Is there a way to change the title of this issue to include “due to unresloved YAML dependency” (and to correct the spelling of “generate”)?

Here it is with the stack trace, if that helps:

PHP Fatal error:  Uncaught Error: Call to undefined method Symfony\Component\Yaml\Yaml::parseFile() in /Users/username/.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php:28
Stack trace:
#0 /Users/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(159): Grasmash\ComposerConverter\Utility\DrupalInspector::findContribProjects('/devdesktop/uts...', 'modules/contrib')
#1 /Users/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(127): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->requireContribProjects(Object(stdClass))
#2 /Users/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(53): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->addRequirementsToComposerJson()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php(242): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->execute(Object(Symfony\Component\Con in /Users/username/.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

I was having the same issue, what helped me was to run the command outside the repository root. The reason for this is that I had symfony/yaml installed in my site and it was using this instead of the global one, and it was an old version that didn’t have the Yaml::parseFile() method.

I was not able to solve this. I did work around it though. It’s ugly but it works:

Go to /home/cap/.composer/vendor/grasmash/composerize-drupal/src/Composer and add

require('/home/cap/.composer/vendor/symfony/yaml/Yaml.php');
require('/home/cap/.composer/vendor/symfony/yaml/Parser.php');
require('/home/cap/.composer/vendor/symfony/yaml/Dumper.php');
require('/home/cap/.composer/vendor/symfony/yaml/Escaper.php');
require('/home/cap/.composer/vendor/symfony/yaml/Unescaper.php');
require('/home/cap/.composer/vendor/symfony/yaml/Inline.php');

at the top after public function execute(InputInterface $input, OutputInterface $output) { replacing /home/cap with your global composer directory.

I was getting the same message. I think it fails on the very last step of the process - which is updating Drupal core.

I found this still works if you ignore the symfony error message and proceed as follows:

  1. Delete your existing vendor directory,

  2. composer update drupal/core --with-dependencies

  • the result for me was it updates several plugins, but says that drupal/core is not installed, so it did not update core. Maybe you can just run “composer update” instead?
  1. Then I did this: composer require drupal/core This did the update to Drupal 8.5.1

Then run drush updb to update the database.

This also doesn’t add your modules into your composer.json file - you’ll need to run composer require statements for them if you want them tracked. IE: composer require drupal/module_name