-
-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate:module gives Fatal error: Call to a member function getPath() #4118
generate:module gives Fatal error: Call to a member function getPath() #4118
Comments
I ran just gm command with no options and simply answered questions.. this worked. Guessing one of the arguments no longer matches the documentation. Perhaps a better error message would be useful? |
Hi @liquidcms The problem is that you are using an absolute path that doesn't exist in the If you try
Everything will work fine, I will change the examples in the languages repository. Thank you. |
I got this error too, even I don't use the absolute module path. 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).
|
I found why my problem, the path |
@solody thank for your report, could you create a new issue, thanks in advance |
I'm back again, I found that it's a bug actually. |
I encountered this same problem from my Drupal root folder. Changing the module path from module/custom to web/module/custom fixed the problem. Encountered this again and was able to fix by not specifying dependencies. Didn't need to include 'web' for the module path. |
For me it works if no dependencies are specified. |
this was my work around as well. |
For me clearly the problem was trying to create composer.json. Answering no to relevant question allowed for the operation to complete. |
Actually, the error occures if BOTH composer.json and dependencies are selected. (-n option used to avoid extra questions) This works, creates a composer file, no dependencies This also works, adds dependencies, no composer file This fails and does not create the composer.json file Composer 1.9.3 |
I am also running into this. Here is ComposerGenerator::generate():
I don't have any answers, I just ran into this and attempted to trace it down. Also confirmed that this appears to work when not using the |
I just created a pull request to try to address this. The PR doesn't really fix the issue, but it provides some more helpful information. Running the generator will appear as this on error instead of the stack trace you see now:
Also note, if you want to try re-running the command, you will need to delete the previously generated files. |
Isn't it funny when you google an issue and first result in Google is the post you made a year ago. anyway, still getting this error a year later. Looking through comments above i was able to get it working by removing --composer and then also answering no when it asked if i wanted to include dependencies. Also, when using module_path as "/modules/custom", i thought it was odd that it was trying to create the module in D:\Git\Git\modules\custom when i ran the command from the docroot of my site: E:/web/drupal8/web. When i specified absolute path it put the new module in the correct location (E:/www/drupal8/web/modules/custom). |
Hi, I was working with Drupal Console and when I was using the drupal gm command (generate module) I got this error message:
My context: Generating a new Drupal Custom module in a interactive way, yes to composer.json file and yes to dependencies.
|
Hey guys, As @johnbburg mentioned the composer.json is generated through through ComposerGenerator::generate(). But the function So you can only generate a composer.json IF you generated the module in the modules folder of your drupal root where it is discoverable for Drupal. This logic is faulty because (I think most) developers generate their modules outside of the webroot so they can require their module through composer itself. This is the correct procedure to keep dependency management intact. My proposal is to add the --module-path option that is defined in: drupal-console/src/Command/Generate/ModuleCommand.php Lines 122 to 127 in e582d88
As an optional option to: And if this option is set use that path, instead of the (empty) path provided by the extensionManager. So for now, if you want to generate modules with a composer.json it's best to generate it in the default location modules/custom so Drupal can provide the path in which to generate the composer.json. After that you can just move the module to where you prefer it. I'll see if I can provide a patch for you guys in the coming days. |
I have not tried that PR, but this fails even when in modules/custom:
It's worth noting that it did generate all of the expected files except for composer.json. It is thus slightly different than (I think) described by @verbruggenalex but that solution may well resolve it. I'm not in an ideal position to test that at the moment so this is purely informational. :) |
just try hole thing same except [composer.json]->no: |
[ ISSUE-GROUP ] Short description
The ISSUE-GROUP should be one of:
generate:module
Problem/Motivation
Just set up console and tried to run gm command.
drupal generate:module
--module="Qleva"
--machine-name="qleva"
--module-path="/modules"
--description="Custom functions for Qleva mini-site."
--core="8.x"
--package="Qleva"
--module-file
gives:
Fatal error: Call to a member function getPath() on null in E:\www\drupal8a\vendor\drupal\console\src\Generator\ComposerGenerator.php on line 46
Details to include:
How to reproduce
Include steps related how to reproduce.
Details to include:
drupal site:status
).8.7.3
composer show | grep drupal/console
).1.9.1
drupal --version
).1.9.1
drupal generate:module
--module="Qleva"
--machine-name="qleva"
--module-path="/modules"
--description="Custom functions for Qleva mini-site."
--core="8.x"
--package="Qleva"
--module-file
The text was updated successfully, but these errors were encountered: