Using Trellis without a repo_subtree_path

Hello!

I’m experimenting with Trellis to find a repository setup that will work best for our team setup.

The documentation describes that repo_subtree_path is optional:
https://roots.io/trellis/docs/deploys/

In my experiment, I have the recommended folder setup but with a separate repo for Trellis, another for Bedrock and repo_subtree_path commented out in the staging wordpress_sites.yml.

During the deployment step, I get the following error:

TASK [deploy : Fail if composer.json not found] *********************************************************************************************************************************************************************************
System info:
Ansible 2.3.1.0; Linux
Trellis at “Option to install WP-CLI packages”

Unable to find a composer.json file in the root of ‘/srv/www/example.com/releases/20170623094327’. Make sure your repo has
a composer.json file in its root or edit repo_subtree_path for ‘example.com’ in wordpress_sites.yml so it points to the
directory with a composer.json file.
fatal: [server]: FAILED! => {“changed”: false, “failed”: true}

The error makes sense since there is no site subtree in the repository. Is there a recommended way to use Trellis without a repo_subtree_path defined?

What does the folder structure of your repo look like?

Trellis needs a composer.json to exist in the root of that repo, otherwise you can point it to the path of the Bedrock folder via repo_subtree_path.

2 Likes

I agree with @swalkinshaw’s post above. I had all this typed so I’ll share it anyway…


:arrow_up: Normally your steps should work.

Could you try temporarily replacing your staging repo value with the following (and leave the repo_subtree_path commented out):

repo: git@github.com:roots/bedrock.git

If deploying this basic bedrock repo succeeds, it suggests that your own repo doesn’t have the composer.json file in the root (perhaps you simply haven’t yet pushed your local git changes to your remote repo?).

If the above test still fails with the same message, could you try temporarily editing the production group_vars/production/wordpress_sites.yml, replacing the repo value again with the basic bedrock repo above and commenting out the repo_subtree_path, then run your deploy again, still with -e env=staging? If now the deploy succeeds, it suggests that production variables are coming in to play even when you use -e env=staging, which would likely be a symptom of this problem (see link for solution).

2 Likes

Thanks, @swalkinshaw and @fullyint.

Using the Bedrock repo solves the problem.

I think I understand now. The repo needs to be a link to a Bedrock project (which should have a composer.json in the root). Does this sound about right?

If this is the case, would it make sense to update the docs to make this a bit clearer? I don’t mind submitting some suggestions in a pull request.

If there’s a place to clarify that then sure :thumbsup:

I guess you thought it pointed to the Trellis repo?

1 Like

That’s exactly right, @swalkinshaw! I thought it was the URL to the Trellis repo :sweat_smile: