Drupal-console: PHP Fatal error: Call to undefined function Drupal\Console\Launcher\Utils\pcntl_exec()

Created on 12 May 2017  Β·  38Comments  Β·  Source: hechoendrupal/drupal-console

A team member gets this error when upgrading the launcher to RC19. Not sure what this means a.t.m.

PHP Fatal error:  Call to undefined function Drupal\Console\Launcher\Utils\pcntl_exec() in phar:///usr/local/bin/drupal/src/Utils/Launcher.php on line 34

Fatal error: Call to undefined function Drupal\Console\Launcher\Utils\pcntl_exec() in phar:///usr/local/bin/drupal/src/Utils/Launcher.php on line 34
bug

Most helpful comment

Works! Thanks! πŸ‘πŸ»

All 38 comments

Works! Thanks! πŸ‘πŸ»

can't find 'Launcher.php',
it says can't find file to patch at input line 14

I also encountered this and I am also not sure where Launcher.php is.

Hi @xieyanxy9 and @jdleonard,

The patch is meant for Drupal Console Launcher. Drupal Console consists of a few separate packages of which the launcher makes sure you can enter the "drupal" command in your command line and then actually runs Drupal Console from your project. The launcher is installed globally on your system.

To apply this patch, you'll have to clone the launcher repository, then recompile the phar file and then replace your globally installed one. On mac it should be located in '/usr/local/bin'.

@nvaken I used phar-composer to recompiled the phar file, But there is so many packages, which one is correct?
image

I'm not really familiar with phar compiling, but does that not just compile a new phar based on a existing composer package? ( @jmolivas ?) If so, you're probably not able to apply the patch before compile time? Anyway, the package in question is drupal/console-launcher.

A temporary workaround which I use until a new release of the launcher is released is cloning the repository, patching that and then use binary symlinked in /usr/local/bin/. Something like this (untested):

# Clone the repo and change dir to local repo
$ git clone https://github.com/hechoendrupal/drupal-console-launcher.git
$ cd drupal-console-launcher/

# Checkout the latest RC, to make sure we have a pretty solid release
$ git checkout 1.0.0-rc19

# Install composer dependencies
$ composer install

# Patch the Launcher
$ patch -p1 < /path/to/downloaded/patch

# Remove the old launcher binary (optional: only if installed)
$ rm /usr/local/bin/drupal

# Create symlink to drupal console launcher binary in /usr/local/bin/drupal (probably already exists, remove the existing first)
$ ln -s /path/to/drupal-console-launcher/bin/drupal /usr/local/bin/drupal

Hope that helps.

@xieyanxy9 We use https://github.com/box-project/box2 for creating the phar

As mentioned by @nvake if you are planning to use this in you local machine you can probably skip the phar generation and only symlink it like:

ln -s /path/tot/drupal-console-launcher/bin/drupal /usr/local/bin/drupal

Hey guys thanks for the help,
Symlink didn't work see screenshot http://pasteboard.co/6GAkXEP9r.png.
Also tried to building a phar file with "box build" command after "composer install" and got the same error Call to undefined function Drupal\Console\Launcher\Utils\pcntl_exec().

Hi @geolivero, you might want to check if your /usr/local/bin is in your $PATH. Run echo $PATH to check.

Also, whats the output of ls -l /usr/local/bin/drupal?

Thank you and yes /usr/local/bin is in my PATH
this is my output.
ls -l /usr/local/bin/drupal
-rwxr-xr-x+ 1 username staff 158754 May 15 22:37 /usr/local/bin/drupal

Looks like your old phar file is still in place. You could create a backup of that file if you'd like or just delete it (rm /usr/local/bin/drupal). Then, rerun the creating of the symlink from the repository, I suspect that you're all set after that.

Edit: I'll edit my above step-by-step to include the removal of the phar, to make sure this doesn't happen again.

These are all the steps i took.

➜ drupal-console-launcher git:(6b711dd) git apply -v ./102.patch
Checking patch src/Utils/Launcher.php...
Applied patch src/Utils/Launcher.php cleanly.
➜ public git:(dev) βœ— rm /usr/local/bin/drupal
➜ public git:(dev) βœ— which drupal
drupal not found
➜ public git:(dev) βœ— ln -s ~/Desktop/drupal-console-launcher/bin/drupal /usr/local/bin/drupal
➜ public git:(dev) βœ—
➜ public git:(dev) βœ— which drupal
/usr/local/bin/drupal
➜ public git:(dev) βœ— drupal generate:module

Fatal error: Call to undefined function Drupal\Console\Launcher\Utils\pcntl_exec() in /Users/contact/Sites/projecten/web/partyyard/public/vendor/drupal/console-launcher/src/Utils/Launcher.php on line 34

@jmolivas yes ;)
➜ drupal-console-launcher git:(6b711dd) βœ— patch -p1 < ~/Desktop/drupal-console-launcher/102.patch
patching file src/Utils/Launcher.php
Reversed (or previously applied) patch detected! Assume -R? [n] y
The CD to the drupal site dir and ....
➜ public git:(dev) βœ— drupal
Fatal error: Call to undefined function Drupal\Console\Launcher\Utils\pcntl_exec() in /Users/contact/Desktop/drupal-console-launcher/src/Utils/Launcher.php on line 34

Ok I cleaned up everything and started all over again and now i get:

➜ public git:(dev) βœ— drupal generate:module
Warning: passthru(): Unable to fork [vendor/bin/drupal generate:module] in /path/to/website/public/vendor/drupal/console-launcher/src/Utils/Launcher.php on line 46

Erm... I'm lost on that error. Somehow the launcher seems to be installed in your project?

I know it does, i cannot get this to work.
Maybe better to wait for the update? I will use drush for the time being ;( as much as I love drupal console.

This what i tried

➜ public git:(dev) βœ— composer remove drupal/console
Dependency "composer/installers" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "doctrine/annotations" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "guzzlehttp/guzzle" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/css-selector" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/dom-crawler" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/http-foundation" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/process" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "stecman/symfony-console-completion" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/console" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/dependency-injection" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/event-dispatcher" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/process" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/translation" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/yaml" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "twig/twig" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/yaml" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "symfony/console" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 12 removals

  • Removing drupal/console (1.0.0-rc19)
  • Removing drupal/console-core (1.0.0-rc19)
  • Removing dflydev/dot-access-configuration (v1.0.1)
  • Removing dflydev/dot-access-data (v1.1.0)
  • Removing dflydev/placeholder-resolver (v1.0.2)
  • Removing drupal/console-en (1.0.0-rc19)
  • Removing symfony/config (v2.8.20)
  • Removing drupal/console-extend-plugin (0.6.0)
  • Removing alchemy/zippy (0.4.3)
  • Removing symfony/filesystem (v2.8.20)
  • Removing gabordemooij/redbean (v4.3.4)
  • Removing symfony/expression-language (v2.8.20)
    Writing lock file
    Generating autoload files

Drupal\Core\Composer\Composer::preAutoloadDump
Drupal\Core\Composer\Composer::ensureHtaccess
➜ public git:(dev) βœ— drupal
Could not find DrupalConsole in the current site (/Users/contact/Sites/projecten/web/partyyard/public).
Please execute: composer require drupal/console:~1.0
➜ public git:(dev) βœ— composer require drupal/console:~1.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals

  • Installing symfony/expression-language (v2.8.20): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing gabordemooij/redbean (v4.3.4): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing symfony/filesystem (v2.8.20): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing alchemy/zippy (0.4.3): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing drupal/console-extend-plugin (0.6.0): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing symfony/config (v2.8.20): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing drupal/console-en (1.0.0-rc19): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing dflydev/placeholder-resolver (v1.0.2): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing dflydev/dot-access-data (v1.1.0): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing dflydev/dot-access-configuration (v1.0.1): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing drupal/console-core (1.0.0-rc19): Loading from cache
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  • Installing drupal/console (1.0.0-rc19): Loading from cache
    Skipped installation of bin bin/drupal for package drupal/console: name conflicts with an existing file
    Drupal\Core\Composer\Composer::vendorTestCodeCleanup
    alchemy/zippy suggests installing guzzle/guzzle (To use the GuzzleTeleporter with Guzzle 3)
    Writing lock file
    Generating autoload files
    Drupal\Core\Composer\Composer::preAutoloadDump
    Drupal\Core\Composer\Composer::ensureHtaccess
    ➜ public git:(dev) βœ— drupal

Fatal error: Call to undefined function Drupal\Console\Launcher\Utils\pcntl_exec() in /path/to/website/public/vendor/drupal/console-launcher/src/Utils/Launcher.php on line 34

Yeah, probably better to wait for the release. For your information; drupal/console, drupal/console-core and drupal/console-en should be installed per project. drupal/console-launcher should be installed system wide.

Add composer install to @nvaken's instructions above, and then they're golden.

Good one, I'll add it to my instructions

I'm trying to install Drupal Console for the first time and I'm getting the same pcntl_exec() error. Is there a reasonable way to get it to work, or should I wait until there's an update for the Launcher? If so, how long do you think it will take for an update?

Same here, looking forward to a release that fixes this issue.

agreed . Please let us know when there is a simple fix so we can use composer with 8.3.2! many thanks.

Same Warning: pcntl_exec() for me. Updated from rc16 -> rc19 and Drupal 8.3.2

same do'h...

Yeah, probably better to wait for the release. For your information; drupal/console, drupal/console-core and drupal/console-en should be installed per project. drupal/console-launcher should be installed system wide.

But how, the docs only show a global binary
https://hechoendrupal.gitbooks.io/drupal-console/content/en/getting/launcher.html

Hi @betz, it has been noted that the docs are a bit vague on that subject and a issue has been filed to address that problem. Though, if you check the main chapter of that page, you'll find a decent explanation:
https://hechoendrupal.gitbooks.io/drupal-console/content/en/getting/project.html

Can you try updating to latest RC20 and validate is this still happening.

Make sure you update Launcher and Site installation.

The pcntl_exec() error is gone, and I can get Drupal Console to work in one setup. However, in another setup I'm getting:

Recoverable fatal error: Argument 2 passed to Drupal\Console\Command\Config\ExportCommand::__construct() must implement interface Drupal\Core\Config\StorageInterface, none given in /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/drupal/console/src/Command/Config/ExportCommand.php on line 43 #0 /Users/foo/Documents/foo-www/html/dru8-upgd/core/includes/bootstrap.inc(552): _drupal_error_handler_real(4096, 'Argument 2 pass...', '/Users/foo/D...', 43, Array)
#1 /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/drupal/console/src/Command/Config/ExportCommand.php(43): _drupal_error_handler(4096, 'Argument 2 pass...', '/Users/foo/D...', 43, Array)
#2 [internal function]: Drupal\Console\Command\Config\ExportCommand->__construct(Object(Drupal\Core\Config\ConfigManager))
#3 /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/symfony/dependency-injection/ContainerBuilder.php(936): ReflectionClass->newInstanceArgs(Array)
#4 /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/symfony/dependency-injection/ContainerBuilder.php(476): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), 'console.config_...')
#5 /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/drupal/console/src/Application.php(192): Symfony\Component\DependencyInjection\ContainerBuilder->get('console.config_...')
#6 /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/drupal/console/src/Application.php(63): Drupal\Console\Application->registerCommands()
#7 /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/symfony/console/Application.php(126): Drupal\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/drupal/console/bin/drupal.php(71): Symfony\Component\Console\Application->run()
#9 /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/drupal/console/bin/drupal(4): require('/Users/foo/D...')
#10 {main}
Recoverable fatal error: Argument 2 passed to Drupal\Console\Command\Config\ExportCommand::__construct() must implement interface Drupal\Core\Config\StorageInterface, none given in Drupal\Console\Command\Config\ExportCommand->__construct() (line 43 of /Users/foo/Documents/foo-www/html/dru8-upgd/vendor/drupal/console/src/Command/Config/ExportCommand.php).

@Gribnif try rebuilding cache drupal cr all

That worked, thanks. Apparently, "drupal cr all" is more thorough than "drush cr", because I did that several times today and still couldn't get console to work.

It works πŸ‘ Thank you

rc20 resolved this for me, thanks!

Closing this one. Feel free to re-open if still happening after updating to the latest version.

You save my day, thank you πŸ‘

I have the same error. How do I update to rc20?

Too lazy to UTFG. :-) drupal self-update did the job.

Was this page helpful?
0 / 5 - 0 ratings