Hello Everyone,

I had a functioning Drupal 8 site and decided to install Drupal Commerce. I followed the instructions to do so using composer. After installation, attempting to visit my homepage now redirects me to /core/install.php

Checking the error log gives me:
PHP Fatal error:  Cannot redeclare config_get_config_directory() (previously declared in /home/***/public_html/****/core/includes/bootstrap.inc:179) in /home/***/public_html/****/web/core/includes/bootstrap.inc on line 192

I did a little digging online but can't seem to find any fix. Hopefully you guys can help?!

Thanks!

Comments

blevine13’s picture

I am also experiencing this error after doing a composer install.

greenskunk’s picture

I'm having the same issue on an account that uses the Drupal Lightning project after running "composer update". I've looked at the folders and files and see that it downloaded Drupal again in the vendor folder. /home/account/vendor/drupal/core and /home/account/docroot/core

I've removed the vendor directory to have composer rebuild it and it downloads drupal and modules into the vendor folder again.

On your account it downloaded it to
/home/***/public_html/****/core
and
/home/***/public_html/****/web/core.

"It is a damn poor day when you don't learn something!" - Mr. Jones, teacher

ytsurk’s picture

Make sure you have

"composer/installers": "^1.2",
in composer.json

aha - interesting ..

mmjvb’s picture

    "installer-paths": {
      "docroot/core": ["type:drupal-core"],
      "docroot/profiles/{$name}": ["type:drupal-profile"],
      "docroot/modules/contrib/{$name}": ["type:drupal-module"],
      "docroot/themes/contrib/{$name}": ["type:drupal-theme"]

These settings and the plugin composer/installers place drupal in the right places. Obviously, drupal/core should declare composer/installers as requirement. As that is not the case currently, you need to make sure for your project it is included.

As other types depend on drupal/core they don't have that need. Only the types of extensions supported in later versions of composer/installers should specify their version constraint.

nofue’s picture

The suggestion to add appropriate installer paths is great, but the "docroot/" part of the template may vary in any specific installation. So don't just copy the suggestion to your composer.json but check what the drupal-root directory actually is. By default it's "web/" 

Norbert

-- form follows function

mmjvb’s picture

Have seen html, docroot and web or it is not used. Wouldn't call it drupal-root either. The terminology used is web-root within project-root. Where web-root is called DocumentRoot in VirtualHost for Apache. When downloading Drupal from d.o. you get a project based on drupal/legacy-project where web-root and project-root are the same location. Projects based on drupal/recommended-project have the web-root called web in the project-root.

The path you need to provide is relative to the project-root. 

nofue’s picture

Regarding this document "web" might be considered the "suggested web-root" in most Drupal installations and it might be helpful for less experienced users not to post snippets which may fail on "noobs". It's about time to make Drupal "noob-friendly".

Norbert

-- form follows function

mmjvb’s picture

Keep dreaming.

castor-designs’s picture

Hi have the exact same problem as OP 4 years later and I am wondering what path I have to put as described here.

My Drupal installation runs inside /home/myname/drupal-installation-folder

So what do I have to put in this json file? thanks in advance.

nofue’s picture

Not every installation is equal, and to get helpful support, you should tell at least the versions and modules in effect. 

Maybe posting your composer.json will put everything in perspective in an instant. 

However, have you tried <code>composer update -W --dry-run</code> already? If there are any error messages you should post these as well.

Norbert

-- form follows function

castor-designs’s picture

Hi nofue

Wow, thank you very much for your reply, your time and effort! Here is more information:

Any help is much appreciated!

nofue’s picture

There's a lot going on, and I would be honestly concerned about the downgrades in your Composer output. But dealing with a broken 9.x installation is far beyond my capabilities. I would 

  1. get back to the state before the update
    (by providing the then working composer.json and renaming composer.lock to f.e. composer.lock.bak to have composer.lock recreated)
  2. Once working again, make a complete backup, including the database
  3. composer require drupal/upgrade_status 

and try to get the site to D10. Dealing with an unsupported vs. 9 installation is like walking on broken glass -- it may hurt if you don't set steps carefully. 

Hope this helps.

Norbert

-- form follows function

castor-designs’s picture

Hi Norbert, thank you so much.

Ah don't worry. Of course I backed everything up and I only broke my staging.

The thing is: I am already trying to upgrade to Drupal 10. But in terms of gettign to Drupal 10 I was adviced to upgrade all modules inside Drupal 9 first.

That's why I got this error int he first place.

If I may ask: What is "composer require drupal/upgrade_status "?

I am currently following this guide to migrate from 9 to 10: https://www.drupal.org/docs/upgrading-drupal/upgrading-from-drupal-8-or-...

nofue’s picture

Upgrade Status is a Module which helps you upgrading to 10 -- highly recommended, as it knows which modules won't work with 10, so you won't try to run impossible upgrade routes (which may be the cause of the downgrades you see with composer).

I prefer this guideline for a 9 -> 10 upgrade:
https://www.drupal.org/docs/upgrading-drupal/upgrading-from-drupal-8-or-...

And yes, it also wants you to go to the latest version of core & modules, but I'd rather do this step by step manually when composer update -W fails. You have to find the version which worked with D9.5 and put this version number in your composer.json file, one at a time. In case trouble occurs, you have only to deal with one module, not with all the dependencies. 

Norbert

-- form follows function

castor-designs’s picture

Thanks Norbert

Actually I am already running Upgade Status I figured and it gives the following report:

    Environment is incompatible: CKEditor (4)
    Remove: 2 projects (Custom Theme Modules for Sliders and such)
    Update: 4 projects
    Collaborate with maintainers: 6 projects (Mailchimp, Ludwig, Simple Image Rotate)
    Fix with rector: 3 projects (Custom Theme Modules)
    Fix manually: 1 project (Custom Theme Module)

I don't quite unterstand this line: "You have to find the version which worked with D9.5 and put this version number in your composer.json file, one at a time. In case trouble occurs, you have only to deal with one module, not with all the dependencies. "

But I think it's because I don't understand how composer works fully.

So you are saying you don't runn all updates, but you go into the composer file and write the latest module number version module after module to see if it works?

How to apply the change once you change the composer.json file? Do you have to run cron or update.php?

nofue’s picture

First: If upgrade_status wants you to remove custom stuff, but you want to keep it, you may try to change dependency in the module.info.yml file. Adding  <code>| 10</code> might do the trick. But save this for later, once 10 is up and running.

Regarding the line you didn't get: If I can avoid, I don't run trial and error with module versions by changing version numbers line by line. This is only the very last resort in case everything else fails. 

From the report, I'd remove those six projects where the maintainers haven't released a working version yet and look for alternatives. Then I'd remove the four custom theme modules, and then run <code>composer update --dry-run</code> If this doesn't show any downgrades, I'd retry with option -W -- if there are still no downgrades shown, run the update. 

Composer has plenty of smart features, one is running composer require with the option of --no-update -- the required module is put into the .json file, but nothing is installed. Using this feature allows you to deal with conflicting modules/versions. By postponing with --no-update you can work with various versions next time you issue composer update.

To put any changes in composer.json to effect, simply run composer update. But if you follow the hints from upgrade_status and the "upgrade 9 to 10" article, you should be fine soon.

All the best!

Norbert

-- form follows function

castor-designs’s picture

Thank you so much Norbert! Last thing: What is happening when I get errors when trying to upgrade to the latest version of a now incompatible module? So I am on Drupal 9.5 and I see that Mailchimp is incompatible.

However, I see that my installed version is 2.1.0-rc1.

The current version is 2.2.2.

So I run: composer require 'drupal/mailchimp:^2.2'

By doing that I hope to patch my old Mailchimp to the latest which hopefully is compatible with Drupal 10 and I have one less module in my incompatible list.

However, this now throws me the following error:

 Problem 1
    - drupal/mailchimp 2.2.0 requires thinkshout/mailchimp-api-php 3.0.0-rc4 -> found thinkshout/mailchimp-api-php[3.0.0-rc4] but it does not match your minimum-stability.
    - drupal/mailchimp[2.2.1, ..., 2.2.2] require thinkshout/mailchimp-api-php 3.0.0 -> found thinkshout/mailchimp-api-php[v3.0.0] but it conflicts with your root composer.json require (^2.1).
    - Root composer.json requires drupal/mailchimp ^2.2 -> satisfiable by drupal/mailchimp[2.2.0, 2.2.1, 2.2.2].

What is happening here?

nofue’s picture

This is the perfect scenario for the --no-update option.

Once you're ready to upgrade, you issue the upgrade command with the --no-update command. Then you issue individual requires, also with the --no-update command. Once everything is put in place, you issue composer update and everything happens miraculously just in time. I think this is also (somewhat) explained in the "upgrade 9 to 10" article I linked before.

Norbert

-- form follows function

nofue’s picture

Thanks for the hint, after 'composer update' my very basic 8.9.0 site collapsed and showed a blank screen with …/install.php in the uri field of the browser. Yikes. Inserting 

"require": { 
      "composer/installers": "^1.2",
      ...

got the site back on its feet. Thanks a ton.

Norbert

-- form follows function

marcelovani’s picture

Not sure how suddenly I got into this problem. The solution by nofue worked.

Technical Architect | Lead Software Engineer

mmjvb’s picture

In my opinion it should be a dependency of drupal/core. My understanding is that it was a dependency of drupal/core-recommended, but was removed. As you need it to get extensions to drupal at the right destination you need to make sure it is required in your project.

kevster’s picture

Yes this simple tip fixed my commerce site thanks - I must admit composer has been driving me nuts and Ive spent way too much time fixing issues and finding fixes from what should be trivial updates etc... 

Drupal development | SEO optimised build

loze’s picture

Even after adding 

"require": { 
      "composer/installers": "^1.2",
      ...

Removing the vendors dir an reinstalling with composer install,

Composer is still putting drupal files in the vendors directory and im getting the error: PHP Fatal error:  Cannot redeclare config_get_config_directory()

My installer paths are:

"installer-paths": {
            "core": [
                "type:drupal-core"
            ],
            "modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/contrib/{$name}": [
                "type:drupal-drush"
            ],
            "modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ],
            "libraries/{$name}": [
                "type:drupal-library"
            ]
        }

Everything had been working fine before.

any suggestions?

mmjvb’s picture

The composer.lock contains the calculated result of an install of a certain moment in time. That includes the destination specifications. Your specifications in composer.json are not recalculated by an install, you would need to update for that to happen. Obviously, when there is no composer.lock it gets created by install because version constraints need to be resolved. 

Use `composer update --lock` for a limited update. It won't resolve version constraints for those already there.