How to update Drupal 8 modules manually (from the command line)

There was a Drupal 8 module security update today for the Metatag module, and for some reason I couldn’t get Composer commands like these to work:

composer update drupal/metatag --with-dependencies
composer require 'drupal/metatag:^1.8'
composer require 'drupal/metatag:~1.8'

The Composer output showed it was doing the update, and it definitely made changes to the composer.json file, but when I looked at the Metatag files on the filesystem (under modules/metatag) they weren’t updated, the CHANGELOG file still showed v1.5, and the Drupal admin UI said the same thing. I read articles like this one, but they didn’t help.

Installing Drupal 8 modules manually

I finally gave up and installed several Drupal 8 modules manually. The basic process is more or less the same as it has been with previous Drupal versions:

  • Backup your website and database as usual
  • Download the desired module onto your server as a TGZ or ZIP file using wget, ftp, whatever (I downloaded the Metatag v1.8 release as a TGZ file)
  • Run drush cr
  • Run drush sset system.maintenance_mode 1
  • Unpack the TGZ/ZIP file in the proper place (under modules)
  • Run drush entup
  • Run drush updatedb
  • Run drush sset system.maintenance_mode 0
  • Run drush cr
  • Test the website
  • Remove the TGZ/ZIP file you downloaded

After I did this I checked the website admin pages, such as admin/reports/updates, and everything now shows as being updated properly.

Why Composer didn’t work(?)

I have no idea why Composer was failing to work properly with my Drupal 8 modules. When I ran this command it clearly shows it thinking it downloaded Metatag v1.8, but that wasn’t the case:

$ composer update drupal/metatag --with-dependencies
<more boilerplate output here>
Package operations: 0 installs, 1 update, 0 removals
  - Updating drupal/metatag (1.7.0 => 1.8.0): Downloading (100%)         

I didn’t look into how to debug Composer, I was in a rush to get the security updates installed so I gave up on Composer and installed the modules manually.

In summary, if you ever need to install Drupal 8 modules manually from the command line, I hope the commands and process shown are helpful.

Update: Using Composer to show module information

As a brief update — and mostly just as a “note to self” — during the process described above I ran this composer info command, and got the output shown:

$ composer info drupal/metatag --all

name     : drupal/metatag
descrip. : Manage meta tags for all entities.
keywords : Drupal, seo
versions : 1.x-dev, * 1.8.0, 1.7.0, 1.6.0, 1.5.0, 1.4.0, 1.3.0, 1.2.0, 1.1.0, 1.0.0, 1.0.0-beta12, 1.0.0-beta11, 1.0.0-beta10, 1.0.0-beta9, 1.0.0-beta8, 1.0.0-beta7, 1.0.0-beta6, 1.0.0-beta5, 1.0.0-beta4, 1.0.0-beta3, 1.0.0-beta2, 1.0.0-beta1, dev-1.x
type     : drupal-module
license  : GNU General Public License v2.0 or later (GPL-2.0+) (OSI approved) https://spdx.org/licenses/GPL-2.0+.html#licenseText
source   : [git] https://git.drupal.org/project/metatag 8.x-1.8
dist     : [zip] https://ftp.drupal.org/files/projects/metatag-8.x-1.8.zip 8.x-1.8
names    : drupal/metatag

support
source : http://cgit.drupalcode.org/metatag
issues : http://drupal.org/project/issues/metatag

requires
drupal/core *
drupal/token ^1.0

requires (dev)
drupal/devel ^1.0
drupal/metatag_dc *
drupal/metatag_open_graph *
drupal/page_manager ^4.0
drupal/redirect ^1.0
drupal/restui ^1.0
drupal/schema_metatag ^1.0
drupal/schema_web_page *

When I have more time I’ll look into this more, but I wanted to show those results here before I delete all my scratch notes on what I went through during this module update process.