grasmash / composerize-drupal

Convert a non-Composer-managed Drupal application (e.g., one created via tarball) to a Composer-managed Drupal application.
MIT License
125 stars 20 forks source link

Unable to geenrate composer file #3

Closed rockaholiciam closed 6 years ago

rockaholiciam commented 6 years ago

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.

justcaldwell commented 6 years ago

Same issue: on first attempt, all composer.json and .lock files are deleted as expected, then the error above.

Additional attempts yield the exception below (despite providing a valid Drupal root):

[Exception]
Unable to find Drupal root directory. Please change directories to a valid Drupal 8 application. Try specifying it with --drupal-root

justcaldwell commented 6 years ago

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
mikehues commented 6 years ago

Similar behavior. Lot's of composer.json files are delete, but I end up with these errors:

PHP Fatal error: Call to undefined method Symfony\Component\Yaml\Yaml::parseFile() in /Users/.../.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

Fatal error: Call to undefined method Symfony\Component\Yaml\Yaml::parseFile() in /Users/.../.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

JWinTX commented 6 years ago

Same here. Centos7 PHP 7.1.8

$ composer composerize-drupal --composer-root=. --drupal-root=. Created composer.json PHP Fatal error: Uncaught Error: Call to undefined method Symfony\Component\Yaml\Yaml::parseFile() in /home/devtest/.config/composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php:28 Stack trace:

0 /home/devtest/.config/composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(159): Grasmash\ComposerConverter\Utility\DrupalInspector::findContribProjects('/home/devtest/p...', 'modules/contrib')

1 /home/devtest/.config/composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(127): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->requireContribProjects(Object(stdClass))

2 /home/devtest/.config/composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(53): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->addRequirementsToComposerJson()

3 /usr/share/php/Symfony/Component/Console/Command/Command.php(259): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->execute(Object(Symfony\Component\ in /home/devtest/.config/composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

wfredk commented 6 years ago

I have the same problem. FreeBSD 11.1, PHP 5.6.34

I tried composer require symfony/yaml but that didn't make any difference.

% composer composerize-drupal --drupal-root=drupal Assuming that composer.json should be generated at drupal. Is this correct? y Created composer.json PHP Fatal error: Class 'Symfony\Component\Yaml\Yaml' not found in /web/spacecolonists/.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

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

wfredk commented 6 years ago

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")?

bbondier commented 6 years ago

Same issue here. CentOS 7 / PHP 7.1.11

Aalve commented 6 years ago

Attempting a global install of Symfony's YAML component with composer didn't work either: composer global require symfony/yaml

Running the composerize command afterward yielded the same result. I'd like to switch my drupal installation over to a composer managed one so that I can update to 8.5.1 as soon as possible.

wheelercreek commented 6 years ago

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?
  3. 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

ChristianAdamski commented 6 years ago

Adding

$a = new \ReflectionClass('DrupalFinder\DrupalFinder');
var_dump($a->getFileName());

$a = new \ReflectionClass('Symfony\Component\Yaml\Yaml');
var_dump($a->getFileName());

at the start of ComposerizeDrupalCommand.php shows that the former file is found, the latter is not.

ChristianAdamski commented 6 years ago

I just let the global composer generate the optimized static classmaps, and it does everything correctly:

...
'Symfony\\Component\\Yaml\\Tag\\TaggedValue' => $vendorDir . '/symfony/yaml/Tag/TaggedValue.php',
    'Symfony\\Component\\Yaml\\Unescaper' => $vendorDir . '/symfony/yaml/Unescaper.php',
    'Symfony\\Component\\Yaml\\Yaml' => $vendorDir . '/symfony/yaml/Yaml.php',
    'Webmozart\\Assert\\Assert' => $vendorDir . '/webmozart/assert/src/Assert.php',
    'Webmozart\\PathUtil\\Path' => $vendorDir . '/webmozart/path-util/src/Path.php',
...

I have no idea what is happening :(

ChristianAdamski commented 6 years ago

Calling "composer global composerize-drupal --composer-root=asdf --drupal-root=asdf" from some random directory with random values does change anything either:

[ReflectionException]
Class Symfony\Component\Yaml\Yaml does not exist

ChristianAdamski commented 6 years ago

Resolving any other class works fine though.

ChristianAdamski commented 6 years ago

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.

wgallop99 commented 6 years ago

Same

EgbertBleyenburg commented 6 years ago

Same here Am totally reconfiguring Drupal 8 sites setup by amateurs (a.k.a. designers) Classes are present but composerize can't find them composer global require symfony/yaml didn't solve it ChristianAdamski 's solution worked for me, so thanx!

glouton commented 6 years ago

Hello, Same here saddly. :(

Just installed composerize_drupal to update from 8.5.5 to 8.5.6.

OS: CentOS Linux release 7.5.1804 (Core) PHP: 7.2.8

$ composer composerize-drupal --composer-root=. --drupal-root=.
Created composer.json
PHP Fatal error:  Uncaught Error: Call to undefined method Symfony\Component\Yaml\Yaml::parseFile() in /home/glouton/.config/composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php:28
Stack trace:
#0 /home/glouton/.config/composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(159): Grasmash\ComposerConverter\Utility\DrupalInspector::findContribProjects('/Nightcrawler/p...', 'modules/contrib')
#1 /home/glouton/.config/composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(127): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->requireContribProjects(Object(stdClass))
#2 /home/glouton/.config/composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(53): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->addRequirementsToComposerJson()
#3 /usr/share/php/Symfony/Component/Console/Command/Command.php(241): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->execute(Object(Symfony\Component\ in /home/glouton/.config/composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

This stack trace is displayed twice.

EgbertBleyenburg commented 6 years ago

Did ChristianAdamski 's solution not work for you....?

glouton commented 6 years ago

Hi there,

Was about yo try ChristianAdamski 's solution when I relalised his path refers to a Symfony package inside his home's vendor. Which I don't have. I guess it should use the Symfony/Component from the vendor directory at the root of the Drupal installation.

Anyway, after a few rm, require, install, update... manualy checking the content of composer.json at the root of the project I ended up with Drupal 8.5.6 installed. Go figure. XD

I'm such in a hury with this project, already lost half a day so I'm gonna focus on building it and I'll come back to this issue later. ;o)

Regards

ucola commented 6 years ago

same issue with php 7.1, any ideas to solve this?

composer composerize-drupal --composer-root=. --drupal-root=webroot Created composer.json PHP Fatal error: Uncaught Error: Class 'Symfony\Component\Yaml\Yaml' not found in /home/username/.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php:28 Stack trace:

0 /home/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(159): Grasmash\ComposerConverter\Utility\DrupalInspector::findContribProjects('/home/username/w...', 'modules/contrib')

1 /home/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(127): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->requireContribProjects(Object(stdClass))

2 /home/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(53): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->addRequirementsToComposerJson()

3 phar:///home/username/composer.phar/vendor/symfony/console/Command/Command.php(241): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Objec in /home/username/.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

Fatal error: Uncaught Error: Class 'Symfony\Component\Yaml\Yaml' not found in /home/username/.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php:28 Stack trace:

0 /home/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(159): Grasmash\ComposerConverter\Utility\DrupalInspector::findContribProjects('/home/username/w...', 'modules/contrib')

1 /home/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(127): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->requireContribProjects(Object(stdClass))

2 /home/username/.composer/vendor/grasmash/composerize-drupal/src/Composer/ComposerizeDrupalCommand.php(53): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->addRequirementsToComposerJson()

3 phar:///home/username/composer.phar/vendor/symfony/console/Command/Command.php(241): Grasmash\ComposerConverter\Composer\ComposerizeDrupalCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Objec in /home/username/.composer/vendor/grasmash/composerize-drupal/src/Utility/DrupalInspector.php on line 28

dungahk commented 4 years ago

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.