I thought this might be useful to the community. When using Kinsta, after the initial deploy, the composer.json file wasn’t being updated on new deploys. (Commits and everything were a-ok.)
So I did some digging and found this updated bit in this guide written by @ben.
I am having the same issue and not sure how to get this resolved. Here’s is my file.
---
- block:
- name: Remove WordPress transient containing old release path
shell: "{{ project.multisite.enabled | default(false) | ternary('wp network meta delete 1', 'wp option delete') }} _site_transient_theme_roots ||:"
args:
chdir: "{{ deploy_helper.current_path }}"
register: site_transient_theme_roots
changed_when: site_transient_theme_roots.stdout != ''
when: project.update_wp_theme_paths | default(update_wp_theme_paths | default(true)) | bool
- name: Update WP theme paths
command: >
wp option set {{ item[0].option }}
{{ item[1] | regex_replace('.*' + deploy_helper.releases_path + '/[^/]*(.*)', deploy_helper.new_release_path + '\1') }}
{% if project.multisite.enabled | default(false) %} --url={{ item[1].split(' ')[0] }}{% endif %}
args:
chdir: "{{ deploy_helper.current_path }}"
when: project.update_wp_theme_paths | default(update_wp_theme_paths | default(true)) | bool
with_subelements:
- "[{% for result in wp_template_root.results %}{'option': '{{ result.item }}', 'stdout_lines': {{ result.stdout_lines | default ([]) | select('search', deploy_helper.releases_path) | list }}},{% endfor %}]"
- stdout_lines
- name: Warn about updating network database.
debug:
msg: "Updating the network database could take a long time with a large number of sites."
when: project.update_db_on_deploy | default(update_db_on_deploy) and project.multisite.enabled | default(false)
- name: Update WP database
command: wp core update-db {{ project.multisite.enabled | default(false) | ternary('--network', '') }}
args:
chdir: "{{ deploy_helper.current_path }}"
when: project.update_db_on_deploy | default(update_db_on_deploy)
when: wp_installed.rc == 0
- name: Install Composer dependencies - Kinsta fix
composer:
command: install
working_dir: /www/project_358/public/current/web/app/themes/sage
- name: Clear Kinsta cache
uri:
url: "{{ site_env.wp_home }}/kinsta-clear-cache-all/"
method: GET
Everything completes successfully this way but then it tells still tells me me to run composer install from the sage directory. So I SSH in, navigate to the sage directory and run that command. The site loads but all my resources are missing.
and deploy to Kinsta, I get the following error in my terminal and it won’t complete:
We were unable to read either as JSON nor YAML, these are the errors we got
from each:
JSON: No JSON object could be decoded
Syntax Error while loading YAML.
expected <block end>, but found '-'
The error appears to be in '/Volumes/LaCie/_development/_trellis/_hybrid/trel
lis.project.build/trellis/roles/deploy/hooks/finalize-after.yml': line 36,
column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Install Composer dependencies - Kinsta fix
^ here
fatal: [kinsta_staging]: FAILED! => {"reason": "We were unable to read either as JSON nor YAML, these are the errors we got from each:\nJSON: No JSON object could be decoded\n\nSyntax Error while loading YAML.\n expected <block end>, but found '-'\n\nThe error appears to be in '/Volumes/LaCie/_development/_trellis/_hybrid/trellis.project.build/trellis/roles/deploy/hooks/finalize-after.yml': line 36, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Install Composer dependencies - Kinsta fix\n ^ here\n"}
The documentation on Kinsta and Roots should be updated to help solve issue.
I tried but they’re unwilling to help with this. It appears moving the composer and cache block up above wp_installed solved the issue and the working directory path has to be the theme path vs the /current path.