wp-cli: For development, how can I activate a theme that is on the local disk but not zipped?

[S/O to @TomJNowell whose comments helped me track down the issue. Sharing in case it could help others troubleshoot a similar problem]

In my setup, I’m using two Docker containers with different images:

  • wordpress:4.9: wp container
  • wordpesss:cli: wp-cli container

In order to allow wp-cli container access to the WordPress config, files, etc., I configured them to share a named volume mounted to /var/www/html/.

For the most part, this worked as intended. However, I discovered that the volume mount /var/www/html/wp-content/themes/foobar -> (local theme dir) was only configured for the wp container and not wp-cli. This makes sense of why wp command:

  1. Couldn’t find the stylesheet
  2. Wasn’t listing the local theme

When I was verifying that the theme directory existed, I was only looking at the wp container and not wp-cli as I assumed both had the same volumes mounted.

Once I modified the docker config and mounted the theme directory on wp-cli, everything worked as expected.

Note: Once I discovered my mistake, tested the command in multiple CWD, including root (/). Each time I received the same results.