It’s that time again! Drupal 9 will be released later this year and it’s never too late to test patches and contribute. Thinking about it, I wondered how to quickly test patches and install Drupal 9 from my local Git checkout. When I say quickly it means it really should be dead simple, by typing one command only. The idea being to make sure I’d always install Drupal from the 9.0.x branch at the latest commit to follow changes.

Check anavarre/d9 on Github

I came up with a Python script to achieve just that on Linux. It should work on Mac but it’s untested. The idea is this:

  • Install Drupal 9 with the --install parameter
  • Wipe everything (really, delete all containers and go back to a clean Git repo) with the --wipe parameter

It looks like this upon installing Drupal:

$ d9 --install
===> Drupal 9 codebase detected
===> Git repository detected
===> composer.json detected
===> Pulling Composer dependencies
===> Creating Lando configuration file
===> Starting app
Let's get this party started! Starting app..
Recreating landoproxyhyperion5000gandalfedition_proxy_1 ... done
Creating network "drupal9_default" with the default driver
Creating volume "drupal9_data_appserver" with default driver
Creating volume "drupal9_home_appserver" with default driver
Creating volume "drupal9_data_database" with default driver
Creating volume "drupal9_home_database" with default driver
Creating drupal9_appserver_1 ... done
Stopping drupal9_appserver_1 ... done
Starting drupal9_appserver_1 ... done
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100   599  100   599    0     0   1109      0 --:--:-- --:--:-- --:--:--  1109
100 4673k  100 4673k    0     0  2290k      0  0:00:02  0:00:02 --:--:-- 6138k
Drush Commandline Tool 10.2.2
Stopping drupal9_appserver_1 ... done
Starting drupal9_appserver_1 ... done
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100  811k  100  811k    0     0   111k      0  0:00:07  0:00:07 --:--:--  144k
Stopping drupal9_appserver_1 ... done
Starting drupal9_appserver_1 ... done
Creating drupal9_database_1  ... done
Waiting until database service is ready...
Waiting until appserver service is ready...
Waiting until database service is ready...
Waiting until database service is ready...
Waiting until database service is ready...
Waiting until database service is ready...
Waiting until database service is ready...
Waiting until database service is ready...
Waiting until database service is ready...

BOOMSHAKALAKA!!!

Your app has started up correctly.
Here are some vitals:

NAME            drupal9                                
LOCATION        /home/{your_username}/Sites/git/drupal/drupal 
SERVICES        appserver, database                    
APPSERVER URLS  https://localhost:33335                
http://localhost:33336                 
http://drupal9.lndo.site:8080          
https://drupal9.lndo.site              

===> Installing Drupal

// You are about to create a sites/default/settings.php file and DROP all tables in your 'drupal8' database. Do you  
// want to continue?: yes.                                                                                           

[notice] Starting Drupal installation. This takes a while.
[success] Installation complete.
https://drupal9.lndo.site/user/reset/1/1583080437/QcSKuNYakHrJ53IObRxSQYeq954ohvHPIywgcPHXcGY/login

And upon wiping everything:

$ d9 --wipe
WARNING: This will completely destroy the Lando app. Are you sure? (y/n) y
===> Deleting app
Preparing to resign drupal9 to the dustbin of history...
Stopping drupal9_database_1  ... done
Stopping drupal9_appserver_1 ... done
Removing drupal9_database_1  ... done
Removing drupal9_appserver_1 ... done
Removing network drupal9_default
Removing volume drupal9_data_appserver
Removing volume drupal9_home_appserver
Removing volume drupal9_data_database
Removing volume drupal9_home_database
Your app has paid the IRON PRICE. App destroyed!
WARNING: This will reset your Git repo and pull the latest commit in HEAD. Are you sure? (y/n) y
===> Delete /path/to/git/checkout/drupal/vendor directory
===> Delete /path/to/git/checkout/drupal/sites/default directory
[sudo] password for {username}:
===> Pulling latest changes
Removing .lando.yml
HEAD is now at 44ee417272 Issue #3111244 by bnjmnm, sasanikolic, lauriii: Update SortableJS to 1.10.2
Already up to date.

A few more notes

At the time of this writing I’m using the drupal8 Lando recipe. I filed an issue to get an official recipe for drupal9, which means the script will - hopefully soon - be even simpler (no need to create and manage a .lando.yml file or to install Drush). There’s a PR about it in case you’re interested and wish to contribute.