deployer icon indicating copy to clipboard operation
deployer copied to clipboard

Incompatible declaration when using AWS SDK in deploy.php

Open seb-enovate opened this issue 10 months ago • 13 comments

  • Deployer version: 7.3.3

We are using the AWS SDK within our deploy.php file to fetch some data that we need for our deployments. However, since upgrading to more recent versions of the AWS SDK (version 3.303.4 in our case) we have been getting the following error when doing deploys (truncated for brevity):

PHP Fatal error:  Declaration of RingCentral\Psr7\Request::getRequestTarget() must be compatible with Psr\Http\Message\RequestInterface::getRequestTarget(): string in phar:///root/.composer/vendor/deployer/deployer/dep/vendor/ringcentral/psr7/src/Request.php on line 63
PHP Stack trace:
PHP   1. {main}() /root/.composer/vendor/bin/dep:0
PHP   2. include() /root/.composer/vendor/bin/dep:119
PHP   3. require() /root/.composer/vendor/deployer/deployer/dep:4
PHP   4. Deployer\Deployer::run($version = '7.3.3', $deployFile = '/builds/clients/target-zero-booking-system/deploy.php') phar:///root/.composer/vendor/deployer/deployer/dep/bin/dep:96
...

I believe the issue is that the AWS SDK changed their version constraint of the psr/http-message package to allow either 1.x or 2.x in this commit.

Now Deployer's version constraint for the same package is ^1, and I think this is allowing the package to jump to 2.x somehow.

Running the following command in my project that uses Deployer fixes the issue:

composer require "psr/http-message" "^1.1"

I also note that in the output of that composer command it says the following:

  - Downgrading psr/http-message (2.0 => 1.1)

So I think that the psr/http-message version constraint in Deployer's composer.json needs to be updated to be more restrictive and prevent that package jumping to 2.x.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

seb-enovate avatar Apr 10 '24 15:04 seb-enovate

Do you ise Deployer at master?

antonmedv avatar Apr 11 '24 05:04 antonmedv

Hi Anton,

We are using version 7.3.3, if that is what you are asking?

Thanks

Seb

seb-enovate avatar Apr 11 '24 08:04 seb-enovate

This is strange b/c deployed tagged version comes bunddled. No dependencies.

antonmedv avatar Apr 11 '24 10:04 antonmedv

Not sure if this is helpful but we are installing Deployer like this:

composer require "deployer/deployer" "^7.0.1"

And then installing the AWS SDK like this:

composer require "aws/aws-sdk-php"

seb-enovate avatar Apr 11 '24 10:04 seb-enovate

@antonmedv Sorry to chase, but we're still hitting this issue, would it help if we submitted a PR that adds a version constraint for the psr/http-message that resolves the issue?

mtwalsh avatar May 22 '24 14:05 mtwalsh

@mtwalsh I guess you're using master branch. Try to switch a version tag.

antonmedv avatar May 22 '24 16:05 antonmedv

I can confirm this is an issue. Running into it with Deployer 7.4.0 and AWS SDK 3.316.0.

harmenjanssen avatar Jul 09 '24 04:07 harmenjanssen

Two approaches for solutions I have on my mind:

  • have a seperate composer.json file for deployer (this is what we do, mainly, because we don't want composer to dictate our php version or dependency versions 🙈 )
  • use deployer.phar file.

Schrank avatar Jul 11 '24 08:07 Schrank

Maybe that helps: https://andreas.heigl.org/2024/06/02/of-tools-and-dependencies/

Schrank avatar Jul 11 '24 08:07 Schrank

Maybe that helps: https://andreas.heigl.org/2024/06/02/of-tools-and-dependencies/

Hmm, that's an interesting philosophy. I was not aware that you could actually use multiple composer.json files. Thanks for sharing!

harmenjanssen avatar Jul 12 '24 04:07 harmenjanssen

Hi, any update?

FrancescoASessa avatar Jul 29 '24 19:07 FrancescoASessa

We're using Polar.sh so you can upvote and help fund this issue.

antonmedv avatar Aug 02 '24 07:08 antonmedv

I think what we need to do is to vendor all symphony dependencies. Create a subject inside deploy rename all the namespaces. Delete all dependencies from composer.

This should be a relatively simple to do. Also with this we can simplify bundling process of Deployer release.

antonmedv avatar Aug 06 '24 03:08 antonmedv

This issue has been automatically closed. Please, open a discussion for bug reports and feature requests.

Read more: [https://github.com/deployphp/deployer/discussions/3888]

github-actions[bot] avatar Sep 09 '24 20:09 github-actions[bot]

This issue has been automatically closed. Please, open a discussion for bug reports and feature requests.

Read more: [https://github.com/deployphp/deployer/discussions/3888]

github-actions[bot] avatar Sep 09 '24 20:09 github-actions[bot]