hechoendrupal / drupal-console

The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
http://drupalconsole.com
GNU General Public License v2.0
939 stars 559 forks source link

Drupal 9 composer install console is not able to pick the correct path through autoloader vendor/bin/drupal #4312

Open ayappans opened 3 years ago

ayappans commented 3 years ago

Drupal 9 composer install console is not able to pick the correct path through autoloader vendor/bin/drupal

Problem/Motivation

When I install Drupal console using composer, it installs successfully and but when you execute it it throw the following error. Warning: require(/opt/drupal/vendor/drupal/console/bindrupal.php): Failed to open stream: No such file or directory in /opt/drupal/vendor/bin/drupal(21) : eval()'d code on line 3

Fatal error: Uncaught Error: Failed opening required '/opt/drupal/vendor/drupal/console/bindrupal.php' (include_path='.:/usr/local/lib/php') in /opt/drupal/vendor/bin/drupal(21) : eval()'d code:3 Stack trace:

0 /opt/drupal/vendor/bin/drupal(21): eval()

1 {main}

thrown in /opt/drupal/vendor/bin/drupal(21) : eval()'d code on line 3 Details to include:

Steps

  1. composer create-project drupal/recommended-project . 2 composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader
  2. drupal it throws the above error. I solved this problem by changing the following code in vendor/console/bin/drupal.php
#!/usr/bin/env php
<?php
require __DIR__. '/drupal.php';

The code the drupal binary starts working. This require DIR is existing other composer modules. Not sure why it is not there. Could you please update this?

errauch commented 3 years ago

I also have this problem on Windows 10 with PHP 7.4

ayappans commented 3 years ago

Please make the above changes it will solve the problem