Skip to content

[ *generate:module* ] Error: Call to a member function getPath() on null when module name starts with a number #4147

Closed

Description

@Xarno

Problem/Motivation

When generating a module with a number as first char the drupal console throws an error.
I had no idea why and tried around for half an hour. That case should handled properly.

How to reproduce

drupal generate:module --module="3rdparty_roles" --machine-name="3rdparty_roles" --module-path="modules/custom" --description="Allow granting roles to users at signup time. For that a list of allowed users is maintained." --core="8.x" --package="Custom" --module-file

Result:

// generate:composer
Error: Call to a member function getPath() on null in /Users/name/repositories//vendor/drupal/console/src/Generator/ComposerGenerator.php on line 46 #0 /Users/name/repositories//vendor/drupal/console/src/Command/Generate/ComposerCommand.php(410): Drupal\Console\Generator\ComposerGenerator->generate(Array)
#1 /Users/name/repositories//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 /Users/name/repositories//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 /Users/name/repositories//vendor/symfony/event-dispatcher/EventDispatcher.php(212): Drupal\Console\Core\EventSubscriber\CallCommandListener->callCommands(Object(Symfony\Component\Console\Event\ConsoleTerminateEvent), 'console.termina...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#4 /Users/name/repositories//vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'console.termina...', Object(Symfony\Component\Console\Event\ConsoleTerminateEvent))
#5 /Users/name/repositories//vendor/symfony/console/Application.php(1014): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('console.termina...', Object(Symfony\Component\Console\Event\ConsoleTerminateEvent))
#6 /Users/name/repositories//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 /Users/name/repositories//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 /Users/name/repositories//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 /Users/name/repositories//vendor/symfony/console/Application.php(148): Drupal\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /Users/name/repositories//vendor/drupal/console/bin/drupal.php(89): Symfony\Component\Console\Application->run()
#11 /Users/name/repositories//vendor/drupal/console/bin/drupal(4): require('/Users/name...')
#12 {main}
Error: Call to a member function getPath() on null in Drupal\Console\Generator\ComposerGenerator->generate() (line 46 of /Users/name/repositories//vendor/drupal/console/src/Generator/ComposerGenerator.php).

Details to include:

  • Drupal version: 8.6.17
  • Console version: 1.9.3
  • Console Launcher version: 1.9.3

Solution

Don't use a number as first char?! If this is forbidden then don't crash. Print a nice error message instead.

Activity

  1. LOBsTerr commented on Sep 10, 2019

    @LOBsTerr
    Member
  2. enzolutions commented on Sep 15, 2019

    @enzolutions
    Contributor

    Fixed with #4148 will be included in 1.9.4 Release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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