1

This is a (25 sites) multisite setup running smoothly on Drupal 9.4 with Drush 10.x still. Upgrading to Drupal 10.1.x and Drush 11 or 12 however makes Drush unusable.

Dir layout as installed by drupal/core-recommended:

/var/www/projectroot/
├── composer.json
├── composer.lock
├── config
│   └── mysite.com
├── vendor
│   ├── asm89
│   │   └── stack-cors
│   ├── behat
│   │   ├── mink
│   │   ├── mink-browserkit-driver
│   │   └── mink-goutte-driver
│   ├── bin
│       └── drush
│   ├── bjeavons
│   │   └── drupal-finder
│   ├── drush
│   │   └── drush
│   │       ├── appveyor.yml
:   :       :
│   │       ├── drush
│   │       └── drush.bat
:   :
│   └── wikimedia
│       └── composer-merge-plugin
└── web
    ├── libraries
    ├── modules
    │   ├── contrib
    │   └── custom
    ├── profiles
    ├── robots.txt
    ├── sites
    │   ├── default
    │   └── mysite.com
    │       ├── files
    │       ├── services.yml
    │       └── settings.php
    ├── sites.php
    ├── themes
    │   └── mytheme
    ├── update.php
    └── web.config

: denotes items I think that are not relevant are left out. The vendor directory is actually much bigger:

$ find vendor | wc -l
41837

composer.json:

{
    "name": "myproject",
    "description": "myproject",
    "type": "project",
    "require": {
        "cweagans/composer-patches": "^1.7",
        "drupal/admin_feedback": "^2.2",
        "drupal/admin_toolbar": "*",
        "drupal/allowed_formats": "^1.3",
        "drupal/animated_gif": "^2.0",
        "drupal/asset_injector": "^2.7",
        "drupal/better_passwords": "2.x",
        "drupal/block_content_machine_name": "dev-3286263-automated-drupal-10 as 3.0.2",
        "drupal/bootstrap_barrio": "^5.1",
        "drupal/ckeditorheight": "^1.8",
        "drupal/config_split": "^2.0@RC",
        "drupal/config_update": "*",
        "drupal/cookies": "^1.0",
        "drupal/core": "10.1.*",
        "drupal/core-composer-scaffold": "10.1.*",
        "drupal/core-project-message": "10.1.*",
        "drupal/core-recommended": "10.1.*",
        "drupal/csv_importer": "^1.15",
        "drupal/draggableviews": "^1.2",
        "drupal/easy_breadcrumb": "^2.0",
        "drupal/editor_file": "*",
        "drupal/facets": "^2.0",
        "drupal/file_extractor": "^4",
        "drupal/fixed_block_content": "dev-3357439-ui-updating-to",
        "drupal/focal_point": "^2.0",
        "drupal/fontyourface": "^3.5",
        "drupal/glossify": "^2.0",
        "drupal/imce": "*",
        "drupal/libraries": "^4.0",
        "drupal/matomo": "^1.12",
        "drupal/menu_block": "*",
        "drupal/menu_breadcrumb": "*",
        "drupal/menu_item_role_access": "^2.0",
        "drupal/menu_trail_by_path": "*",
        "drupal/metatag": "^1.16",
        "drupal/migrate_plus": "^6.0",
        "drupal/migrate_process_url": "^2.0.x-dev",
        "drupal/migrate_tools": "^6.0",
        "drupal/override_node_options": "^2.6",
        "drupal/paragraphs": "^1.12",
        "drupal/paragraphs_edit": "^2.0",
        "drupal/pathauto": "^1.3",
        "drupal/permissions_by_term": "^3.1",
        "drupal/restui": "^1.17",
        "drupal/search_api": "^1.11",
        "drupal/simple_sitemap": "^4.1",
        "drupal/sitemap": "^2.0",
        "drupal/smart_trim": "*",
        "drupal/svg_image": "^1.14",
        "drupal/term_csv_export_import": "^4.0",
        "drupal/toc_js": "^2.1",
        "drupal/tome": "1.8.*",
        "drupal/unique_field_ajax": "^2.0",
        "drupal/user_current_paths": "^2.0",
        "drupal/user_redirect": "^1.0",
        "drupal/video_embed_field": "^2.0",
        "drupal/video_embed_wysiwyg": "^2.0",
        "drupal/views_ajax_history": "^1.2",
        "drupal/views_block_area": "^1.0",
        "drupal/viewsreference": "^2.0",
        "drupal/webform": "^6.0",
        "drush/drush": "^11",
        "http-interop/http-factory-guzzle": "^1.0",
        "guzzlehttp/guzzle": "^7.4",
        "phpmailer/phpmailer": "^6.0",
        "toc/toc": "*",
        "wikimedia/composer-merge-plugin": "^2.0"
    },
    "require-dev": {
        "behat/mink": "*",
        "behat/mink-goutte-driver": "*",
        "drupal/devel": "*",
        "mikey179/vfsstream": "~1.2",
        "phpunit/phpunit": "^9",
        "symfony/css-selector": "^4.4"
    },
    "authors": [
        {
            "name": "me",
            "email": "[email protected]"
        }
    ],
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8",
            "exclude": [ "drupal/search_api_meilisearch", "drupal/better_passwords", "drupal/block_content_machine_name", "drupal/fixed_block_content" ]
        },
        {
            "type": "package",
            "package": {
                "name": "toc/toc",
                "version": "v0.3.2",
                "type": "drupal-library",
                "dist": {
                    "url": "https://raw.githubusercontent.com/jgallen23/toc/greenkeeper/update-all/dist/toc.min.js",
                    "type": "file"
                }
            }
        },
        {
            "type": "git",
            "url": "git@mygitserver:search_api_meilisearch"
        },
        {
            "type": "git",
            "url": "https://git.drupalcode.org/issue/better_passwords-3296626.git"
        },
        {
            "type": "git",
            "url": "https://git.drupalcode.org/issue/block_content_machine_name-3286263.git"
        },
        {
            "type": "git",
            "url": "https://git.drupalcode.org/issue/fixed_block_content-3357439.git"
        }
    ],
    "minimum-stability": "dev",
    "extra": {
        "patches": {
            "drupal/core": {
                "Field options 'Rewrite results' and 'Link to the Content' applied together is not working as expected": "https://www.drupal.org/files/issues/2018-11-12/views_link_trim-2600456-22.patch",
                "Add file-mime formatter and make it output icons": "https://www.drupal.org/files/issues/2021-07-15/2907414-31.patch",
                "Large decimal number do not validate as they should": "https://www.drupal.org/files/issues/2022-07-26/2230909-269.patch",
                "Fix unnecessary multiple settings updates in AJAX calls": "https://www.drupal.org/files/issues/2021-05-12/2771361-42.patch",
                "Add a 'machine_name' widget for string field types with a UniqueField constraint": "https://www.drupal.org/files/issues/2023-05-17/drupal-10-1x-machine-name-widget-2685749-116.patch"
            },
            "drupal/toc_js": {
                "Disable showing the ToC as a default": "patches/toc_js_per_node_default_off.diff",
                "Fix umlaut and trailing special char conversion in ToC": "patches/toc_js_umlaut_and_trailing_char_fix.patch"
            },
            "drupal/metatag": {
                "Unset link rel: shortlink, edit-form, version-history and revision, and meta name: Generator, MobileOptimized, HandheldFriendly, viewport from <head> https://www.drupal.org/project/metatag/issues/2735195": "https://www.drupal.org/files/issues/2021-04-29/metatag-unset-2735195-59.patch"
            },
            "drupal/bootstrap_barrio": {
                "Add missing jquery.once dependency for affix.js (https://www.drupal.org/project/bootstrap_barrio/issues/3278329 and ../3366908) #9505-10": "https://www.drupal.org/files/issues/2023-06-14/3366908-2.patch"
            },
            "drupal/webform": {
                "Fix broken result export with drush": "https://www.drupal.org/files/issues/2023-01-26/3335851-4.patch"
            },
            "drupal/permissions_by_term": {
                "Fix content is not editable with 3.1.22": "https://git.drupalcode.org/project/permissions_by_term/-/merge_requests/20.patch"
            },
            "drupal/facets": {
                "Facets with AJAX not working": "https://www.drupal.org/files/issues/2023-02-07/facets-with-ajax-not-working-in-most-of-situations-3052574-174.patch"
            }
        },
        "drupal-scaffold": {
            "locations": {
                "web-root": "./web"
            }
        },
        "enable-patching": true,
        "installer-paths": {
            "web/core": [ "type:drupal-core" ],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "web/drush/contrib/{$name}": ["type:drupal-drush"],
            "web/themes/custom/{$name}": ["type:drupal-custom-theme"]
        },
        "merge-plugin": {
            "include": [
                "web/modules/contrib/webform/composer.libraries.json"
            ]
        }
    },
    "prefer-stable": true,
    "conflict": {
        "drupal/drupal": "*"
    },
    "config": {
        "sort-packages": true,
        "optimize-autoloader": true,
        "allow-plugins": {
            "composer/installers": true,
            "drupal/console-extend-plugin": true,
            "cweagans/composer-patches": true,
            "drupal/core-composer-scaffold": true,
            "drupal/core-project-message": true,
            "wikimedia/composer-merge-plugin": true,
            "php-http/discovery": true
        }
    }
}

As suggested in the comments, I reduced this to a minimum viable setup:

{
    "name": "myproject",
    "description": "myproject",
    "type": "project",
    "require": {
        "drupal/core": "*",
        "drupal/core-composer-scaffold": "*",
        "drupal/core-project-message": "*",
        "drupal/core-recommended": "*",
        "drush/drush": "*"
    },
    "authors": [
        {
            "name": "me",
            "email": "[email protected]"
        }
    ],
    "minimum-stability": "dev",
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "./web"
            }
        },
        "enable-patching": true,
        "installer-paths": {
            "web/core": [ "type:drupal-core" ],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "web/drush/contrib/{$name}": ["type:drupal-drush"],
            "web/themes/custom/{$name}": ["type:drupal-custom-theme"]
        },
            "merge-plugin": {
            "include": [
                "web/modules/contrib/webform/composer.libraries.json"
            ]
        }
    },
    "prefer-stable": true,
    "conflict": {
        "drupal/drupal": "*"
    },
    "config": {
        "sort-packages": true,
        "optimize-autoloader": true,
        "allow-plugins": {
            "composer/installers": true,
            "drupal/console-extend-plugin": true,
            "drupal/core-composer-scaffold": true,
            "drupal/core-project-message": true,
            "php-http/discovery": true
        }
    }
}

After this, I ran composer update (as the recommended composer update "drupal/core-*" -W would not update drupal/core as it was still locked to 9.4.x). Still no joy.

On Drupal 9.4 and Drush 10.x, I was able to just use drush -l mysite.com when in /var/www/projectroot (or somewhere below, as well).

Now, no matter the CWD, I cannot for the life of me get drush to output meaningful stuff.

user@webserver:/var/www/projectroot/web $ ../vendor/drush/drush/drush --root=sites/mysite.com or user@webserver:/var/www/projectroot $ vendor/bin/drush --root=web/sites/mysite.com or any other parameter combination with -l or --url or using absolute paths does not yield anything meaningful. With drush 11 I get ! [NOTE] Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands.

With is really strange, as drush seems to find the root (last line):

user@webserver:/var/www/projectroot $ vendor/bin/drush st
PHP binary    : /usr/bin/php8.1
PHP config    : /etc/php/8.1/cli/php.ini
PHP OS        : Linux
PHP version   : 8.1.21
Drush script  : /var/www/projectroot/vendor/bin/drush
Drush version : 11.6.0
Drush temp    : /tmp
Drush configs : /var/www/projectroot/vendor/drush/drush/drush.yml
Drupal root   : /var/www/projectroot/web

Drush is installed via composer, as per the docs.

Drush 12 only gives me: The alias references a Drupal site that does not contain its own copy of Drush. Please add Drush to this site to use it. (Note the double blank after alias; I consider this a bug, the error message should be different when a variable is undefined). I can get similar output to Drush 11 if I use @none as an alias.

I don't need aliases and only want to use drush locally on this dev-server. Deployment has its own automatic framework.

Do I need a copy of drush in every multisite's sites/<sitename> dir? I know global drush is not supported anymore, I switched from a system-wide installed drush to one in my project dir installed via composer (like it is still now) back at Drupal 8 and consider this locally installed, but I may be wrong? If so, how?

Happy to provide more debug info if needed.

Thanks in advance for anyone taking a look at this!

8
  • 1
    There is almost nothing in the vendor directory.
    – mona lisa
    Jul 11, 2023 at 17:30
  • How exactly did you upgrade? Can you post your composer.json, too?
    – leymannx
    Jul 12, 2023 at 6:54
  • Updated the description to make clear the vendor dir is actually much bigger. Added composer.json. How did I upgrade? I changed all occurences of 9.4.* in drupal/* packages to 10.1.* and ran composer update -W, fixing all the incompatible packages one by one by either increasing the version or using patches where no stable versions are available, yet.
    – tbart
    Jul 12, 2023 at 8:40
  • I don’t think this is the present issue but that isn’t how it’s done.
    – mona lisa
    Jul 12, 2023 at 10:18
  • I can try with the recommended composer update "drupal/core-*" -W" as per the manual, but this gets really involved as I cannot require and update in one go, which I need as the core update blocks the other packages and vice versa. (I want all versions to be pinned). I have to remove all the packages and re-add them again this way. Did this, and will update the description. But as you said: It did not fix it.
    – tbart
    Jul 12, 2023 at 11:51

2 Answers 2

2

The issue was with composer.json needing another require statement for some version between 9.4 and 10.1, most likely >=10.x.

This fixed all mentioned drush issues regarding ! [NOTE] Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands. or The alias references a Drupal site that does not contain its own copy of Drush. Please add Drush to this site to use it.:

composer require "composer/installers" "^2.0"

Now, if you have a multisite setup that has worked on Drupal 8 and 9 without a web/sites/sites.php file (like me) and just using subdirectories that are called the same way as their URL, it seems you now have to explicitly define them in web/sites/sites.php (instantiate it using example.sites.php; just add $sites['mysite.org'] = 'mysite.org'; for every multisite).

Without that, my drush 12.1 + Drupal 10.1 were not able to correctly determine the site path (always set to sites/default when issuing drush -l mysite.org st).

Make sure your composer.json looks as similar as possible to the one you get with a fresh install as outlined in the official docs, currently at https://www.drupal.org/docs/develop/using-composer/starting-a-site-using-drupal-composer-project-templates. This helped me pinpoint the differences.

I consider this a bug in drush, there should be some check whether the needed packages are installed before failing in a way that does not give users a clue a package is missing.

The sites.php that is now needed should probably be part of the Drupal >=10.x release notes. If anyone knows how to disable the necessity for this, please chime in! This is an additional step in multisite creation/instantiation that is unnecessary imho, if there are no aliases/ports needed. It would be nice to have this as default again.

0

I ran into this but in my case the issue was I was using Docker, where I encountered this error: "Composer plugins have been disabled for safety in this non-interactive session. Set COMPOSER_ALLOW_SUPERUSER=1 if you want to allow plugins to run as root/super user". Adding "COMPOSER_ALLOW_SUPERUSER=1" to my Dockerfile solved it. Hope it helps someone

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.