The theme directory "theme1" does not exist

I have updated Bedrock to 1.7.3, and now get The theme directory “theme1” does not exist. after each deploy.
WP then switches to 2017 and if I then choose my theme1, it works!?

I have now found that the “current” symlink is also pointing to a non-existant release folder.

We don’t have any details of what your deployment setup looks like. Are you using Trellis?

A Bedrock update wouldn’t cause the issues that you are describing

Sorry, yes it’s Trellis, and was working until aprox. Bedrock was updated to 1.7.3.
It’s pretty standard Trellis + Bedrock combo. Trellis is at 0.9.9.

Where does this error appear? On the site or in the output in terminal?

Is your Trellis setup also syncing databases?

Could a plugin be trying to set the default theme somehow and failing? (Have you tried disabling all plugins and redeploying?)

Is your theme accidentally a submodule of your project (this happened to me once when I git cloned rather than using composer and had me confused and frustrated for like two hours)

Does the problem also happen on your Vagrant VM?

1 Like

The error is shown on the front end.
Trellis doesn’t do any db syncing that I know of.
All the plugins installed, are currently deactivated.
Theme is “hardcoded” into /app/themes/ folder, and is available as soon as i clone my Bedrock repo.
But on vagrant there is no deploying, or?

Also as soon as the theme downgrade happens to Twenty 17, and I re-activate my theme, all things work fine.
I think this might be more of a symlink issue that I mentioned, as the “current” symlink in the /srv/www/mysite/ folder seems to be pointing to the release folder that’s a bit old. I tried deleting the symlink, removing all the release folders from /srv/www/fapps.info/releases folder, but no go.

Why was the symlink pointing to an old release if you’ve been deploying? Are you sure there aren’t errors when you deploy?

There are no errors that I see in the terminal history.

Try removing the current directory entirely on the remote server and doing another deploy.

I did that but it didn’t help. It seems that “current” is always pointing to an earlier release (even though there are newer releases successfully deployed to releases folder.
In the mean time got some error about php-fpm, and decided to rebuild the whole machine, re-provisioned and redeployed coupled of times, and the same thing happens.

You gotta be more specific. “some error” isn’t the error, so please provide details.

I’m assuming whatever changes you’ve made to your Trellis or Bedrock projects are causing your conflict. I’m not able to reproduce, so try again with fresh Trellis and Bedrock installs without modifications.

I was facing the same issue with The theme directory "theme1" does not exist with my child theme – no symlink issues though and no deployment errors.

After a bit of debugging I tracked the problem down to the following code in roles/deploy/hooks/finalize-after.yml:

- name: Get WP theme template root
  command: wp option get template_root
  args:
    chdir: "{{ deploy_helper.current_path }}"
  register: wp_template_root
  changed_when: false
  failed_when: wp_template_root.stderr != ""
  when: wp_installed | success

- name: Update WP theme paths
  command: wp option set {{ item }} {{ deploy_helper.new_release_path }}/web/wp/wp-content/themes
  args:
    chdir: "{{ deploy_helper.current_path }}"
  when: wp_installed | success and wp_template_root != '/themes' and wp_template_root != ''
  with_items:
    - stylesheet_root
    - template_root

When I commented out these lines there was no further deployment problems. Not sure why the template and stylesheet root paths are being updated every deploy but it doesn’t appear to work with child themes.

Just wanted to add that I have been experiencing the exact same problem.

I have a custom theme that is included in my git repo for the site, and after each deploy I got the error “The theme directory “MY THEME NAME” does not exist.”.

Commenting out the following worked for me:

- name: Update WP theme paths
  command: wp option set {{ item }} {{ deploy_helper.new_release_path }}/web/wp/wp-content/themes
  args:
    chdir: "{{ deploy_helper.current_path }}"
  when: wp_installed | success and wp_template_root != '/themes' and wp_template_root != ''
  with_items:
    - stylesheet_root
    - template_root

However, I’m not sure if doing that will break anything else…

1 Like

Please see https://github.com/roots/trellis/issues/731 (specific to issues with deploying a child theme) with a temporary fix

2 Likes

EDIT: The fix posted by @ben solves this issue.

I also have this problem.
My trellis deploy was working fine until suddenly it showed this message. My version of Trellis is 0.9.9 from around January 10. Any Hints?