2

I installed Drupal in one click on a OVH server. First bad surprise: I discovered that the installed version 9.1.9 needs a security update to 9.2.9.

Second bad surprise: drush was not installed by default. So I had to install first composer in order to install drush with the command:

curl -sS https://getcomposer.org/installer | php

After some battles, composer was working. I installed drush issuing command:

composer require --dev drush/drush

Probably, the --dev flag was not necessary.

I see that composer is able to list the available updates of drupal by running:

composer show drupal/recommended-project --all
name     : drupal/recommended-project
descrip. : Project template for Drupal 9 projects with a relocated document root
keywords : 
versions : 9.4.x-dev, 9.3.x-dev, 9.3.0-beta2, 9.3.0-beta1, 9.3.0-alpha1, 9.2.x-dev, 9.2.9, 9.2.8, 9.2.7, 9.2.6, 9.2.5, 9.2.4, 9.2.3, 9.2.2, 9.2.1, 9.2.0, 9.2.0-rc1, 9.2.0-beta3, 9.2.0-beta2, 9.2.0-beta1, 9.2.0-alpha1, 9.1.x-dev, 9.1.14, 9.1.13, 9.1.12, 9.1.11, 9.1.10, 9.1.9, 9.1.8, 9.1.7, 9.1.6, 9.1.5, 9.1.4, 9.1.3, 9.1.2, 9.1.1, 9.1.0, 9.1.0-rc3, 9.1.0-rc2, 9.1.0-rc1, 9.1.0-beta1, 9.1.0-alpha1, 9.0.x-dev, 9.0.14, 9.0.13, 9.0.12, 9.0.11, 9.0.10, 9.0.9, 9.0.8, 9.0.7, 9.0.6, 9.0.5, 9.0.4, 9.0.3, 9.0.2, 9.0.1, 9.0.0, 9.0.0-rc1, 9.0.0-beta3, 9.0.0-beta2, 9.0.0-beta1, 9.0.0-alpha2, 9.0.0-alpha1, 8.9.x-dev, 8.9.20, 8.9.19, 8.9.18, 8.9.17, 8.9.16, 8.9.15, 8.9.14, 8.9.13, 8.9.12, 8.9.11, 8.9.10, 8.9.9, 8.9.8, 8.9.7, 8.9.6, 8.9.5, 8.9.4, 8.9.3, 8.9.2, 8.9.1, 8.9.0, 8.9.0-rc1, 8.9.0-beta3, 8.9.0-beta2, 8.9.0-beta1, 8.8.x-dev, 8.8.12, 8.8.11, 8.8.10, 8.8.9, 8.8.8, 8.8.7, 8.8.6, 8.8.5, 8.8.4, 8.8.3, 8.8.2, 8.8.1, 8.8.0, 8.8.0-rc1, 8.8.0-beta1, 8.8.0-alpha1
type     : project
license  : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved) https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText
homepage : https://www.drupal.org/project/drupal
source   : [git] https://github.com/drupal/recommended-project.git 7f83a471aca47ffaa981bc8cb8a0cf615163ae5b
dist     : [zip] https://api.github.com/repos/drupal/recommended-project/zipball/7f83a471aca47ffaa981bc8cb8a0cf615163ae5b 7f83a471aca47ffaa981bc8cb8a0cf615163ae5b
names    : drupal/recommended-project

support
chat : https://www.drupal.org/node/314178
docs : https://www.drupal.org/docs/user_guide/en/index.html
source : https://github.com/drupal/recommended-project/tree/9.4.x

requires
composer/installers ^1.9
drupal/core-composer-scaffold ^9.4
drupal/core-project-message ^9.4
drupal/core-recommended ^9.4

requires (dev)
drupal/core-dev ^9.4

conflicts
drupal/drupal *

My problem is that I installed drupal/drupal that is apparently conflicting with drupal/recommended-project where I see the upgrade of drupal I need.

What should be the next step to upgrade from Drupal 9.1.9 to Drupal 9.2.9? Sorry if this question is trivial, but I am overwhelmed with a huge documentation where I get lost.

UPDATE: this is the composer.json file I found in my home directory:

{
    "require-dev": {
        "drush/drush": "^10.6"
    }
}

And UPDATE2: this is the composer.json file I found in the Drupal root directory:

{
    "name": "drupal/legacy-project",
    "description": "Project template for Drupal 9 projects with composer following drupal/drupal layout",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.9",
        "drupal/core-composer-scaffold": "^9.1",
        "drupal/core-project-message": "^9.1",
        "drupal/core-recommended": "^9.1",
        "drupal/core-vendor-hardening": "^9.1"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "./"
            }
        },
        "installer-paths": {
            "core": [
                "type:drupal-core"
            ],
            "libraries/{$name}": [
                "type:drupal-library"
            ],
            "modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/contrib/{$name}": [
                "type:drupal-drush"
            ],
            "modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "profiles/custom/{$name}": [
                "type:drupal-custom-profile"
            ],
            "themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },
        "drupal-core-project-message": {
            "include-keys": [
                "homepage",
                "support"
            ],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/legacy-project template!               </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",
                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        }
    }
}
Pierre François
  • 5,850
  • 1
  • 17
  • 38
  • Can you post your composer.json please – leymannx Nov 21 '21 at 16:05
  • It seems you landed in [this situation](https://www.drupal.org/node/2718229#deprecated-drupal-drupal), where the core cannot be updated with Composer. Quoting the important part : _One option to switch your existing drupal/drupal site to the latest recommended composer managed template drupal-composer/drupal-project, is the GoComposer plugin_. This is great because the drupal-composer/drupal-project is also deprecated ! So, if you are familiar with web projects you have better to clean up and restart with a fresh install. A service supposed to make things easy complicates things, thanks OVH.. – EricLavault Nov 21 '21 at 16:50
  • @leymannx: I will update my question and include the `composer.json` file. – Pierre François Nov 21 '21 at 21:12
  • This is the composer.json from inside your Drupal folder? This can't be it. The `composer show` command you've run and the line about the conflict is just telling you that the recommended-project wouldn't let you add drupal/drupal to it. If the composer.json you posted really is the only one inside your project you need to find a way to download the updated core files on you local machine, upload them via FTP and then visit https://example.com/update.php in your browser. But you gonna have a hard time and Drush will be of no help here if your site is not Composer-managed. – leymannx Nov 21 '21 at 23:00
  • Drush won't let you update Drupal core anymore. And [updating core manually](https://www.drupal.org/docs/updating-drupal/updating-drupal-core-manually) is no fun. And at this point @EricLavault indeed might be right you restart from scratch. Now that you have Composer on the host you can run the `composer create-project` command to start a new project. The last resort you can try is installing the new [Automatic Updates](https://www.drupal.org/docs/8/update/automatic-updates) module. – leymannx Nov 21 '21 at 23:13
  • @leymannx: I am already at scratch. I will need a tutorial for the command `composer create-project`. I wonder if I need to uninstall Drupal first. – Pierre François Nov 22 '21 at 07:53
  • No you don't have to uninstall, just [create the project](https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies) in a different folder and then connect the existing database in settings.php and set the domain to the folder where you created the project. – leymannx Nov 22 '21 at 08:13
  • @leymannx: you are right, there was another composer.json file inside the Drupal root directory. What I posted, was the composer.json file of the users home directory, sorry. I have updated my question above in order to include the needed composer.json file. I start to understand you need to run `composer` from inside the root directory of Drupal. – Pierre François Nov 22 '21 at 14:11

2 Answers2

0

If your project is new you can do some actions to be on the last version of drupal. To avoid any conflicts you have to :

rm -rf /vendor
rm composer.lock (this file fix the versions of your dependencies)

then

composer update

It will install last version of every dependencies. In case if you just want to update drupal dependencies do (without delete composer.lock and /vendor) :

composer update drupal/core-recommended --with-dependencies
Sharklalu
  • 339
  • 1
  • 8
  • Thank you. I had already found the answer. Anyway, I am sorry to communicate that we will migrate to Wordpress due to its ease for upgrading. – Pierre François Dec 16 '21 at 10:28
0

I use the inital installation of composer/drush/drupal like this.

The drush part is the important.

composer

PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php7.4.2/bin:$PATH
  php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
  php composer-setup.php
  php -r "unlink('composer-setup.php');"
  sudo mv composer.phar /usr/local/bin/composer
  PATH="$(composer config -g home)/vendor/bin:$PATH"

drush

cd /drushproject/web/

composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

composer global require consolidation/cgr

cgr drush/drush

# correct DrushLog problems (alternatively run once: drush cr)
composer require drush/drush

drupal

drupal --root=/drushproject/web/
Thomas
  • 76
  • 8