I am on a shared host. Before, my Sage 9 theme deployment with
bedrock-capistrano worked fine. After updating to Sage 10.0.0.beta1 I had to fix other issues and haven’t tried deploying until yesterday… and I have some problems… or maybe just questions
In the docs: theme deployment it says that I have to run
composer install on the server and copy over the generated
dist/ folder. My deploy script (
config/deploy.rb) did include both tasks (pastebins: composer install & upload dist folder), and I assumed it should still work fine as it worked in Sage 9.
First, I realised that in Sage 10 there is no
dist/ folder, right now it’s named
public/ and the deployment created another release, but it was incomplete – but this was an easy fix in the deploy script.
Then, I had another error which happened after
... Your lock file does not contain a compatible set of packages. Please run composer update. Problem 1 - ext-psr is present at version 0.6.1 and cannot be modified by Composer - symfony/service-contracts v2.5.0 conflicts with symfony/service-contracts v2.5.0. - symfony/service-contracts is locked to version v2.5.0 and an update of this package was not requested.
I’ve tried the typical: removing
vendor/, running composer update on the server, same locally, then deploying again… no good. And I was not sure about the PSR version and was confused by the weird symfony package conflict.
I thought “maybe it needs to update, not install”, so I modified my aforementioned composer install task from the deploy script to execute
composer update instead of
composer install – guess what, now the deployment finishes with no errors! I noticed that this command actually does perform installation of packages after updating them:
/usr/local/php74/bin/php /usr/local/bin/composer update Loading composer repositories with package information Updating dependencies Lock file operations: 0 installs, 1 update, 0 removals - Downgrading symfony/service-contracts (v2.5.0 => v2.4.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 60 installs, 0 updates, 0 removals - Installing brick/math (0.9.3):... ... (and so on)
Back to the point: am I doing it right?
composer updateactually installs packages, can I assume that this is somewhat the correct way of deploying the theme?
- If I am wrong, and I should be executing
composer installthen perhaps the PSR extension should be updated on the server? Right now it’s at version 1.2…
I am aware that the documentation is being updated… so I am really doing stuff by trial & error.
If anyone got through this lengthy post, and can advise, please let me know.
Some earlier issues that I ran into, maybe someone will find it useful.
Didn’t update theme folder in the
config/deploy.rbscript (doh!), this is essential but apparently can be overlooked… therefore, obviously:
set :theme_dir, 'theme_folder'
At some point I saw this error during deployment:
psr/container 1.1.2 requires php >=7.4.0 -> your php version (7.3.32) does not satisfy that requirement.
I definitely made sure that the domain PHP version is set to 7.4, logged in via SSH and apparently the shell was still using 7.3, so I’ve added an alias for the
phpcommand in .bash_profile to be using 7.4…but this didn’t help.
I finally learned that when you run commands over SSH it uses so called non-login shell. In your deploy config script you can map a command to be using correct paths:
SSHKit.config.command_map[:composer] = "/usr/local/php74/bin/php /usr/local/bin/composer"
You can check PHP version in non-login shell by running
ssh my-server.com 'php -v'.