Skip to content

composer.json generate fail, when generate a new module. #4179

@solody

Description

@solody

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.
#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:

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:
 > Che Migration

 Enter the module machine name [che_migration]:
 > 

 Enter the module Path [modules/custom]:
 > profiles/custom/che/modules/custom

 Enter module description [My Awesome Module]:
 > Che project's migration functionalities.

 Enter package name [Custom]:
 > Che

 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):
 > migrate

 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(1008): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('console.termina...', Object(Symfony\Component\Console\Event\ConsoleTerminateEvent))
#6 /app/vendor/symfony/console/Application.php(254): 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(147): 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).
```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions