Dear All,

successfully upgraded the Drupal version to the latest version 9.3.12 but after running command "drush updb"
getting error like:

$drush updb
PHP Fatal error: Cannot redeclare drupal_get_filename() (previously declared in /var/www/html/q8/.d_project/vendor/drupal/core/includes/bootstrap.inc:189) in /var/www/html/q8/.d_project/web/core/includes/bootstrap.inc on line 164
[warning] Drush command terminated abnormally.

Could you please help me to sort this issue?

CommentFileSizeAuthor
#7 composer.txt6.33 KBtoby_toby

Comments

Toby_toby created an issue. See original summary.

toby_toby’s picture

Title: Drush command terminated abnormally » PHP Fatal error: Cannot redeclare drupal_get_filename()
cilefen’s picture

It looks like another copy of Drupal installed into the vendor directory. How did you upgrade this codebase?

cilefen’s picture

Priority: Major » Normal
toby_toby’s picture

#3 thank you for your response.
using composer command ie, $composer update

cilefen’s picture

You have two copies of Drupal installed there somehow, which is most unusual. Show us the composer.json file.

toby_toby’s picture

StatusFileSize
new6.33 KB

#6 pls find the attached composer.json file in .txt format

pgn5qs’s picture

I have the same exact issue. I was transiently able to get it working again when I downgraded composer back to 2.0.11 but then it recurred. Site completely broken now. WSOD.

Update: Strange but if I downgrade to composer 2.0.11 and then $composer update. This fixes the crash.

cilefen’s picture

Status: Active » Postponed (maintainer needs more info)

composer/installers": false, Is probably the problem. You actually have to allow those plugins or everything installs into vendor then you have two copies.

cilefen’s picture

Title: PHP Fatal error: Cannot redeclare drupal_get_filename() » If you answer "no" the the Composer plugin authorization prompts, important plugins like composer/installers do not execute, which can lead to an instance of Drupal installed into the vendor directory
cilefen’s picture

Title: If you answer "no" the the Composer plugin authorization prompts, important plugins like composer/installers do not execute, which can lead to an instance of Drupal installed into the vendor directory » If you answer "no" to Composer plugin authorization prompts, important plugins like composer/installers do not execute, which can lead to an instance of Drupal installed into the vendor directory
toby_toby’s picture

#9 Perfect, It's worked.
I am changed the value to composer/installers": true,
and removed vendor folder and composer.lock file then ran the composer install command.
after that, successfully ran the drush commands.
Now the issue is solved.
Thank you for your support.

cilefen’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

amit.mall’s picture

#9, #12 not working for me

amitgoyal’s picture

I tried following steps to make it work which are similar to https://www.drupal.org/project/drupal/issues/3276393#comment-14493922,

composer require composer/installers
rm -rf vendor/autoload.php vendor/autoload_runtime.php vendor/composer
composer install

In my case, composer/installers was already set to true. After running the above steps, I was able to clear the cache and run database updates.

siddharthjain’s picture

Thanks @amitgoyal, #16 works for me.