aws / aws-sdk-php-laravel

A Laravel 5+ (and 4) service provider for the AWS SDK for PHP
http://aws.amazon.com/sdkforphp/
Apache License 2.0
1.64k stars 242 forks source link

requirements could not be resolved to an installable set of packages (laravel 10 support) #232

Closed jbartus closed 1 year ago

jbartus commented 1 year ago

Describe the bug

a composer require of this package in a freshly created laravel project errors out

Expected Behavior

the package to install without error

Current Behavior

% php -v
PHP 8.2.6 (cli) (built: May 11 2023 13:02:10) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies
% composer --version                                
Composer version 2.5.7 2023-05-24 15:00:39
% composer create-project laravel/laravel awssdktest
Creating a "laravel/laravel" project at "./awssdktest"
Installing laravel/laravel (v10.2.2)
  - Installing laravel/laravel (v10.2.2): Extracting archive
<snip>
% cd awssdktest
% composer show | grep laravel/framework
laravel/framework                  v10.12.0 The Laravel Framework.
% composer require aws/aws-sdk-php-laravel
./composer.json has been updated
Running composer update aws/aws-sdk-php-laravel
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - aws/aws-sdk-php-laravel[3.8.0, ..., 3.8.1] require aws/aws-sdk-php ~3.0 -> satisfiable by aws/aws-sdk-php[3.0.0, ..., 3.271.3].
    - aws/aws-sdk-php-laravel[1.0.0, ..., 1.0.2] require laravel/framework 4.0.* -> found laravel/framework[v4.0.0, ..., v4.0.11] but it conflicts with your root composer.json require (^10.10).
    - aws/aws-sdk-php-laravel[1.0.3, ..., 1.2.0] require laravel/framework 4.* -> found laravel/framework[v4.0.0, ..., v4.2.22] but it conflicts with your root composer.json require (^10.10).
    - aws/aws-sdk-php-laravel[1.0.4, ..., 1.1.2] require illuminate/foundation 4.* -> found illuminate/foundation[dev-master, 4.0.x-dev (alias of dev-master)] but it does not match your minimum-stability.
    - aws/aws-sdk-php-laravel 2.0.0 requires illuminate/support ~5.0 -> found illuminate/support[v5.0.0, ..., v5.8.36] but these were not loaded, likely because it conflicts with another require.
    - aws/aws-sdk-php-laravel 2.0.1 requires illuminate/support 5.0.* -> found illuminate/support[v5.0.0, ..., v5.0.33] but these were not loaded, likely because it conflicts with another require.
    - aws/aws-sdk-php-laravel[3.0.0, ..., 3.3.2] require illuminate/support ~5.1 -> found illuminate/support[v5.1.1, ..., v5.8.36] but these were not loaded, likely because it conflicts with another require.
    - aws/aws-sdk-php-laravel 3.4.0 requires illuminate/support ~5.1|~6.0 -> found illuminate/support[v5.1.1, ..., v5.8.36, v6.0.0, ..., v6.20.44] but these were not loaded, likely because it conflicts with another require.
    - aws/aws-sdk-php-laravel 3.5.0 requires illuminate/support ^5.1 || ^6.0 || ^7.0 -> found illuminate/support[v5.1.1, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6] but these were not loaded, likely because it conflicts with another require.
    - aws/aws-sdk-php-laravel 3.6.0 requires illuminate/support ^5.1 || ^6.0 || ^7.0 || ^8.0 -> found illuminate/support[v5.1.1, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
    - aws/aws-sdk-php-laravel 3.7.0 requires illuminate/support ^5.1 || ^6.0 || ^7.0 || ^8.0 || ^9.0 -> found illuminate/support[v5.1.1, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.7] but these were not loaded, likely because it conflicts with another require.
    - aws/aws-sdk-php[3.0.1, ..., 3.3.4] require guzzlehttp/psr7 ~1.0 -> found guzzlehttp/psr7[1.0.0, ..., 1.9.1] but the package is fixed to 2.5.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - aws/aws-sdk-php[3.0.0, ..., 3.18.28] require guzzlehttp/guzzle ~5.3|~6.0.1|~6.1 -> found guzzlehttp/guzzle[5.3.0, ..., 5.3.4, 6.0.1, ..., 6.5.8] but it conflicts with your root composer.json require (^7.2).
    - aws/aws-sdk-php 3.18.29 requires guzzlehttp/guzzle ~5.3.1|~6.2.1 -> found guzzlehttp/guzzle[5.3.1, 5.3.2, 5.3.3, 5.3.4, 6.2.1, 6.2.2, 6.2.3] but it conflicts with your root composer.json require (^7.2).
    - aws/aws-sdk-php[3.18.30, ..., 3.69.10] require guzzlehttp/guzzle ^5.3.1|^6.2.1 -> found guzzlehttp/guzzle[5.3.1, 5.3.2, 5.3.3, 5.3.4, 6.2.1, ..., 6.5.8] but it conflicts with your root composer.json require (^7.2).
    - aws/aws-sdk-php[3.69.11, ..., 3.130.3] require guzzlehttp/guzzle ^5.3.3|^6.2.1 -> found guzzlehttp/guzzle[5.3.3, 5.3.4, 6.2.1, ..., 6.5.8] but it conflicts with your root composer.json require (^7.2).
    - aws/aws-sdk-php[3.131.0, ..., 3.173.19] require guzzlehttp/psr7 ^1.4.1 -> found guzzlehttp/psr7[1.4.1, ..., 1.9.1] but the package is fixed to 2.5.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - aws/aws-sdk-php[3.173.20, ..., 3.198.8] require guzzlehttp/psr7 ^1.7.0 -> found guzzlehttp/psr7[1.7.0, ..., 1.9.1] but the package is fixed to 2.5.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - aws/aws-sdk-php[3.199.0, ..., 3.271.3] require guzzlehttp/promises ^1.4.0 -> found guzzlehttp/promises[1.4.0, ..., 1.5.3] but the package is fixed to 2.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires aws/aws-sdk-php-laravel * -> satisfiable by aws/aws-sdk-php-laravel[1.0.0, ..., 1.2.0, 2.0.0, 2.0.1, 3.0.0, ..., 3.8.1].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require aws/aws-sdk-php-laravel:*" to figure out if any version is installable, or "composer require aws/aws-sdk-php-laravel:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Reproduction Steps

composer create-project laravel/laravel awssdktest
cd awssdktest
composer require aws/aws-sdk-php-laravel

Possible Solution

No response

Additional Information/Context

I tried explicitly using laravel 10.1 instead and I get the same error. Also tried going back to 3.8.0 on this package, which gets the same type of error just with a shorter list of packages:

% composer require aws/aws-sdk-php-laravel "3.8.0"   
./composer.json has been updated
Running composer update aws/aws-sdk-php-laravel
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - aws/aws-sdk-php[3.0.1, ..., 3.3.4] require guzzlehttp/psr7 ~1.0 -> found guzzlehttp/psr7[1.0.0, ..., 1.9.1] but the package is fixed to 2.5.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - aws/aws-sdk-php[3.0.0, ..., 3.18.28] require guzzlehttp/guzzle ~5.3|~6.0.1|~6.1 -> found guzzlehttp/guzzle[5.3.0, ..., 5.3.4, 6.0.1, ..., 6.5.8] but it conflicts with your root composer.json require (^7.2).
    - aws/aws-sdk-php 3.18.29 requires guzzlehttp/guzzle ~5.3.1|~6.2.1 -> found guzzlehttp/guzzle[5.3.1, 5.3.2, 5.3.3, 5.3.4, 6.2.1, 6.2.2, 6.2.3] but it conflicts with your root composer.json require (^7.2).
    - aws/aws-sdk-php[3.18.30, ..., 3.69.10] require guzzlehttp/guzzle ^5.3.1|^6.2.1 -> found guzzlehttp/guzzle[5.3.1, 5.3.2, 5.3.3, 5.3.4, 6.2.1, ..., 6.5.8] but it conflicts with your root composer.json require (^7.2).
    - aws/aws-sdk-php[3.69.11, ..., 3.130.3] require guzzlehttp/guzzle ^5.3.3|^6.2.1 -> found guzzlehttp/guzzle[5.3.3, 5.3.4, 6.2.1, ..., 6.5.8] but it conflicts with your root composer.json require (^7.2).
    - aws/aws-sdk-php[3.131.0, ..., 3.173.19] require guzzlehttp/psr7 ^1.4.1 -> found guzzlehttp/psr7[1.4.1, ..., 1.9.1] but the package is fixed to 2.5.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - aws/aws-sdk-php[3.173.20, ..., 3.198.8] require guzzlehttp/psr7 ^1.7.0 -> found guzzlehttp/psr7[1.7.0, ..., 1.9.1] but the package is fixed to 2.5.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - aws/aws-sdk-php[3.199.0, ..., 3.271.3] require guzzlehttp/promises ^1.4.0 -> found guzzlehttp/promises[1.4.0, ..., 1.5.3] but the package is fixed to 2.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - aws/aws-sdk-php-laravel 3.8.0 requires aws/aws-sdk-php ~3.0 -> satisfiable by aws/aws-sdk-php[3.0.0, ..., 3.271.3].
    - Root composer.json requires aws/aws-sdk-php-laravel 3.8.0 -> satisfiable by aws/aws-sdk-php-laravel[3.8.0].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

SDK version used

3.8.1 and 3.8.0

Environment details (OS name and version, etc.)

mac osx 12.6.2

wunc commented 1 year ago

The conflict arises because a default Laravel 10 install requires Guzzle 7, which can install either guzzlehttp/promises ^1.5 or ^2.0. When you install Laravel, it of course installs the latest, i.e. 2.0.

$ composer why guzzlehttp/promises
guzzlehttp/guzzle 7.7.0 requires guzzlehttp/promises (^1.5.3 || ^2.0)

$ composer why guzzlehttp/guzzle
laravel/laravel  -       requires  guzzlehttp/guzzle (^7.2)

However, the aws-sdk-php requires guzzlehttp/promises ^1.4, and composer won't downgrade an already locked and installed dependency without your approval.

So, a workaround is to allow composer to downgrade guzzlehttp/promises, just use what the output suggests, i.e.

$ composer require -W aws/aws-sdk-php-laravel

This worked for me.

Anyway, another way to avoid having to do that is for aws/aws-sdk-php to add support for promises 2.0. I'm not really familiar with it enough to know if that would be easy or hard. Possibly related: https://github.com/aws/aws-sdk-php/issues/2515

GrahamCampbell commented 1 year ago

This is not a bug. You need to use --with-all-dependencies when you run require, so as to downgrade the guzzle promises library. Support for v2 cannot happen until we drop PHP 5 (https://github.com/aws/aws-sdk-php/pull/2697).

jbartus commented 1 year ago

thank you!

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.