I’ve played with it a bit and discovered that if I connect via ssh to my production droplet and remove the /srv/www/domain.com/current/vendor folder and install it again executing composer install without the --no-scripts flag, it works.
Then I’ve searched for the composer install task in the trellis deploy role ( /trellis/roles/deploy/hooks/build-after.yml ) and changed this:
But it doesn’t work either. So maybe this is not the right place to customize the composer install task, but I haven’t found any other place to change that behaviour
The problem is that Koodimonni Language packages needs composer to be executed without the no-scripts flag because it uses scripts to copy the files to their proper place.
I also tried to change the composer task to sth like this but with no luck:
Does anyone know how to force composer to be fired with scripts? I always mean bedrock composer, not sage.
Am I editing the right file /trellis/roles/deploy/hooks/build-after.yml ?
I have this Warning notice when I launch the deploy role:
[WARNING]: You Ansible version is 2.6.2 but this version of Trellis has only been tested for compatability with Ansible 2.4.0.0 -> 2.4.3.0. It is advisable to check for Trellis updates or downgrade your Ansible version.
Maybe I should try downgrading Ansible, but as everything worked like a charm I thought it wasn’t the problem here…
I’ve downgraded to Ansible 2.4.3.0 but the deploy task does the same. Everything is fine except that script part.
The weird thing is if I SSH and do a composer install manually, everything works just fine.
@alwaysblank Can you confirm me that /trellis/roles/deploy/hooks/build-after.yml is the right file I should focus on? I mean, is that file the YAML file in charge of launching the composer install task on Bedrock?
I’m a bit stuck with this as it seems like the options I put there are not even fired …
I changed the name of the task too ( Install Composer dependencies with scripts ) to see in the deploy process if the changes were firing.
The weird thing is that the plugins in my composer json are being installed correctly, and the ones from Koodimonni are installed in the composer cache too, but the operation that transfers the language files to the correct folder (/site/web/app/languages) is not being fired.
You’re attempting to run this script on post-root-package-install. Take a look at the Composer Documentation for script event names: Scripts - Composer The post-root-package-install event has the following description:
post-root-package-install : occurs after the root package has been installed, during the create-project command.
That means it will only be executed when composer create-project is run. composer create-project is not run by Bedrock or Trellis when installing your dependencies. You probably want to use post-install-cmd, which is executed after composer install.
In other words, this is not a Trellis issue: It’s an issue with the configuration of your composer.json file.
But that command comes on a brand new Bedrock install. It seems that lines are used to copy the .env.example file to the site root as .env file when it’s first installed… You mean that I should remove those lines? I don’t know how is that related to the fact that functionality from an independent composer plugin isn’t fired.
I don’t know if it’s a problem with Trellis or the Koodimonni composer plugin itself, but as If I access the production server via SSH, do a manual composer install and everything works fine, it seems like something in the deploy process is not firing the same way as I do it mannually.
Let me sum up and see if I’m wrong with the deploy process:
Maybe I should debug the composer-dropin-installer and see if everything works when deploying. Maybe the files aren’t there when the plugin is trying to move them…
My apologies, I was tired and didn’t look too closely when I thought I’d found the problem. You’re correct about that line: it’s unrelated to your problem.
I’m not sure what Is causing your problem, but my guess is that it may have to do with the vendors folder being copied during a deploy (see: Johnpbloch/wordpress moved to a new configuration and WP goes missing). IIRC Trellis does this to speed up deploys, but it may be that when it does, it prevents the “install” event from happening on your package because it is already “installed” from the perspective of Composer. You might be able to solve the issue by removing vendor from project_copy_folders.
That’s great! @alwaysblank that solved the problem. You are right, I’ve tested it and it works like a charm now!! Thank you very much!!
I didn’t know about that feature to speed up the deploy process. It was driving me mad because all the steps I reproduced manually in the server seem to be right so I couldn’t explain why it wasn’t working.
I can confirm too that leaving no_scripts: yes in /trellis/roles/deploy/hooks/build_after.yml doesn’t let Koodimonni plugin to move the language files when installed, so that part of the file should look like this:
From Oct the 18th I had an issue derived from commenting out the vendor line from project_copy_folders variable. The problem was that I’ve been getting nested current folders on every deploy. I haven’t noticed this problem until now.
The solution is to declare the project_copy_folders variable as an empty array.