Open solody opened 4 years ago
Hi @solody, When you choose the composer option while executing the generate:module command after generating the module, the command send to call the generate:composer command, so it's here when the issue happen to you, because you defined a url in the profiles dir and Drupal Console can't get that path.
We are deciding if the console will have this new feature of recognizing the modules inside the profile dir.
Is that means composer.json generating only works while the module path in /modules/custom ?
Still got error when I use the default path modules/custom
bash-4.4# su - application -c "cd /app/web/sites && \
/usr/local/bin/drupal gm"
// Welcome to the Drupal module generator
Enter the new module name:
> Oauth2 Device Session
Enter the module machine name [oauth2_device_session]:
>
Enter the module Path [modules/custom]:
>
Enter module description [My Awesome Module]:
>
Enter package name [Custom]:
>
Enter Drupal Core version [8.x]:
>
Do you want to generate a .module file? (yes/no) [yes]:
>
Define module as feature (yes/no) [no]:
>
Do you want to add a composer.json file to your module? (yes/no) [yes]:
>
Would you like to add module dependencies? (yes/no) [no]:
> yes
Module dependencies separated by commas (i.e. context, panels):
> simple_oauth
Do you want to generate a unit test class? (yes/no) [yes]:
>
Do you want to generate a themeable template? (yes/no) [yes]:
> no
Do you want proceed with the operation? (yes/no) [yes]:
>
// generate:composer
Error: Call to a member function getPath() on null in /app/vendor/drupal/console/src/Generator/ComposerGenerator.php on line 46 #0 /app/vendor/drupal/console/src/Command/Generate/ComposerCommand.php(410): Drupal\Console\Generator\ComposerGenerator->generate(Array)
#1 /app/vendor/symfony/console/Command/Command.php(255): Drupal\Console\Command\Generate\ComposerCommand->execute(Object(Symfony\Component\Console\Input\ArrayInput), Object(Drupal\Console\Core\Style\DrupalStyle))
#2 /app/vendor/drupal/console-core/src/EventSubscriber/CallCommandListener.php(76): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Drupal\Console\Core\Style\DrupalStyle))
#3 /app/vendor/symfony/event-dispatcher/EventDispatcher.php(214): Drupal\Console\Core\EventSubscriber\CallCommandListener->callCommands(Object(Symfony\Component\Console\Event\ConsoleTerminateEvent), 'console.termina...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#4 /app/vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'console.termina...', Object(Symfony\Component\Console\Event\ConsoleTerminateEvent))
#5 /app/vendor/symfony/console/Application.php(1027): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('console.termina...', Object(Symfony\Component\Console\Event\ConsoleTerminateEvent))
#6 /app/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Drupal\Console\Command\Generate\ModuleCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /app/vendor/drupal/console-core/src/Application.php(188): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /app/vendor/drupal/console/src/Application.php(64): Drupal\Console\Core\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /app/vendor/symfony/console/Application.php(148): Drupal\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /app/vendor/drupal/console/bin/drupal.php(89): Symfony\Component\Console\Application->run()
#11 /app/vendor/drupal/console/bin/drupal(4): require('/app/vendor/dru...')
#12 {main}
Error: Call to a member function getPath() on null in Drupal\Console\Generator\ComposerGenerator->generate() (line 46 of /app/vendor/drupal/console/src/Generator/ComposerGenerator.php).
But it success when i run gcom
command decouplely.
bash-4.4# su - application -c "cd /app/web/sites && \
/usr/local/bin/drupal gcom --module='oauth2_device_session'"
// Welcome to the Drupal Composer file generator
Enter package name [drupal/oauth2_device_session]:
>
Enter package type [drupal-module]:
>
Enter package description []:
>
Do you want to add package keywords? (yes/no) [no]:
>
Enter license information [GPL-2.0+]:
>
Enter project homepage [https://www.drupal.org/project/oauth2_device_session]:
>
Enter mininmal stability (stable, dev, alpha, beta and RC) []:
> dev
Do you want to add authors of the project? (yes/no) [no]:
>
Do you want to add information about support channels? (yes/no) [no]:
>
Do you want to add required packages for the project? (yes/no) [no]:
>
Do you want proceed with the operation? (yes/no) [yes]:
>
Generated or updated files
Generation path: /app/web
1 - modules/custom/oauth2_device_session/composer.json
Generated lines: 7
Hi there - just running into this problem now, 3 months later: I but only run into this error when I specify dependencies (either went prompted, or with --dependencies="panels". If you say "no" when prompted, it will work. If you manually add your dependencies to MODULE.info.yml (and composer.json) later, you'll probably be fine - but I haven't tried that yet.
Duplicate of https://github.com/hechoendrupal/drupal-console/issues/4118
Proposing to copy path of module when generating composer.json during module generation.
composer.json generate fail, when generate a new module.
[ ISSUE-GROUP ] Short description
The ISSUE-GROUP should be one of:
command:gm
Problem/Motivation
Someone created an issues relatively. https://github.com/hechoendrupal/drupal-console/issues/4118
And they said that the reason was using the absolute module path.
but, I got this error too, even I don't use the absolute module path. The module files generate successfully except the composer.json file. What to do :(
Details to include: