March 30, 2019 admin

Upgrading a manually installed Drupal 8.5 to 8.6.13 using Composer

I originally installed Drupal 8 for LearnAshtanga.com manually because it wasn’t really clear to me how to install Drupal core from composer.

Today I needed to upgrade from Drupal 8.5.6 to Drupal 8.6.13. I wanted to do it all through composer.

So here is how I updated my manual Drupal 8 installation using composer.

composer outdated "drupal/*"

Running composer outdated only shows my modules that had updates.

nano composer.json

Looking in my composer.json file I see why. Drupal core is not in my required sections.

{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "require": {
        "composer/installers": "^1.0.24",
        "wikimedia/composer-merge-plugin": "^1.4",
        "drupal/address": "^1.4",
        "drupal/pathauto": "^1.2",
        "drupal/ctools": "^3.0",
        "drupal/views_send": "^1.3",
        "drupal/editor_file": "^1.2",
        "drupal/redirect": "^1.2",
        "drupal/simple_sitemap": "^2.12",
        "drupal/weight": "^3.0",
        "drupal/restui": "^1.16",
        "drupal/s3fs": "^3.0@alpha",
        "drupal/simple_oauth": "^3.13",
        "drupal/views_slideshow": "^4.6",
        "drupal/search_api_solr": "^2.4",
        "drupal/paragraphs": "^1.5",
        "drush/drush": "^9.5"
    },
    "replace": {
        "drupal/core": "^8.5"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },

I  made a backup of my composer.json

cp composer.json composer.json.bk
In the composer.json file under replace I remove “drupal/core”: “^8.5” so replace looks like:
"replace":{

},

I then wanted to require the latest version of Drupal , 8.6.13 so it would be in my composer.json

composer require drupal/core:8.6.12 --update-with-dependencies

As it attempted to update it hit a snag. There was a dependencies on a newer version of Twig. However, composer clearly gives you this message.

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for drupal/core 8.6.12 -> satisfiable by drupal/core[8.6.12].
    - Conclusion: don't install twig/twig v1.38.4
    - Conclusion: don't install twig/twig v1.38.3
    - Can only install one of: twig/twig[v1.35.4, 1.x-dev].
    - Can only install one of: twig/twig[1.x-dev, v1.35.4].
    - Can only install one of: twig/twig[1.x-dev, v1.35.4].
    - drupal/core 8.6.12 requires twig/twig ^1.38.2 -> satisfiable by twig/twig[1.x-dev, v1.38.2, v1.38.3, v1.38.4].
    - Conclusion: don't install twig/twig v1.38.2
    - Installation request for twig/twig (locked at v1.35.4, required as ^1.35.0) -> satisfiable by twig/twig[v1.35.4].
Installation failed, reverting ./composer.json to its original content.

So then I updated Twig via composer.

composer require "twig/twig:1.38.2"

What surprised me here is that this command also initiated composer updated Drupal core as well even though Drupal was not in the require section of my composer.json.

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 1 update, 0 removals
  - Updating twig/twig (v1.35.4 => v1.38.2): Downloading (100%)         
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing brumann/polyfill-unserialize (v1.0.3): Downloading (100%)         
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing typo3/phar-stream-wrapper (v2.1.0): Downloading (100%)         
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  - Installing drupal/core (8.6.13): Downloading (100%) 

I wanted to go ahead and clean this up. I am glad I did because apparently the last command missed a few udpates.

composer require drupal/core:8.6.13 --update-with-dependencies

And now the latest Drupal core is in my composer.json

    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "require": {
        "composer/installers": "^1.0.24",
        "wikimedia/composer-merge-plugin": "^1.4",
        "drupal/address": "^1.4",
        "drupal/pathauto": "^1.2",
        "drupal/ctools": "^3.0",
        "drupal/views_send": "^1.3",
        "drupal/editor_file": "^1.2",
        "drupal/redirect": "^1.2",
        "drupal/simple_sitemap": "^2.12",
        "drupal/weight": "^3.0",
        "drupal/restui": "^1.16",
        "drupal/s3fs": "^3.0@alpha",
        "drupal/simple_oauth": "^3.13",
        "drupal/views_slideshow": "^4.6",
        "drupal/search_api_solr": "^2.4",
        "drupal/paragraphs": "^1.5",
        "drush/drush": "^9.5",
        "twig/twig": "1.38.2",
        "drupal/core": "8.6.13"
    },
    "replace": {
       
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },

I then updated the rest of my modules

composer update

I was getting a few php-fpm 500 errors so I needed to reset php-fpm.

sudo service php-fpm stop
sudo service php-fpm start

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *