Flysystem Google Cloud Storage dependency issue

Thomas Dutrion
5 min readFeb 17, 2022
Composer dependency error output
Composer dependency error for league/flysystem-google-cloud-storage

TL;DR

Follow the merge request on google-auth-library-php regarding the psr/cache:^3.0 issue, and execute the following commands in the following order for a quick and temporary fix.

composer require league/flysystem-bundle
composer require symfony/cache-contracts:^2.0
composer require psr/cache:^2.0
composer require league/flysystem-google-cloud-storage:^3.0

The full story

(how did I think this through)

Upgrading to PHP 8.1 and Symfony 6 has been a breeze… Until I had to use league/flysystem-google-cloud-storage!

First off, let’s follow the official documentation:

php -v
PHP 8.1.2 (cli) (built: Feb 12 2022 19:36:10) (NTS)
Copyright © The PHP Group
Zend Engine v4.1.2, Copyright © Zend Technologies
with Xdebug v3.1.3, Copyright © 2002–2022, by Derick Rethans
with Zend OPcache v8.1.2, Copyright ©, by Zend Technologies
composer - version
Composer version 2.1.11 2021–11–02 12:10:25
composer require league/flysystem-bundle
Using version ^2.2 for league/flysystem-bundle
./composer.json has been updated
Running composer update league/flysystem-bundle
Loading composer repositories with package information
Updating dependencies
Lock file operations: 3 installs, 0 updates, 0 removals
- Locking league/flysystem (3.0.8)
- Locking league/flysystem-bundle (2.2.0)
- Locking league/mime-type-detection (1.9.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 16 removals
- Removing vich/uploader-bundle (1.19.0)
- Removing rize/uri-template (0.3.4)
- Removing ralouphie/getallheaders (3.0.3)
- Removing psr/http-message (1.0.1)
- Removing psr/http-factory (1.0.1)
- Removing psr/http-client (1.0.1)
- Removing league/flysystem-google-cloud-storage (3.0.8)
- Removing jms/metadata (2.6.1)
- Removing guzzlehttp/psr7 (2.1.0)
- Removing guzzlehttp/promises (1.5.1)
- Removing guzzlehttp/guzzle (7.4.1)
- Removing google/crc32 (v0.1.0)
- Removing google/cloud-storage (v1.26.1)
- Removing google/cloud-core (v1.44.0)
- Removing google/auth (v1.18.0)
- Removing firebase/php-jwt (v5.5.1)
- Upgrading psr/cache (2.0.0 => 3.0.0): Extracting archive
- Upgrading symfony/cache-contracts (v2.5.0 => v3.0.0): Extracting archive
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class…
composer/package-versions-deprecated: …done generating version class
111 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [OK]
Executing script assets:install public [OK]

So far so good! Let’s get dirty and require our Google Cloud Storage library.

composer require league/flysystem-google-cloud-storage:^3.0
./composer.json has been updated
Running composer update league/flysystem-google-cloud-storage
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- league/flysystem-google-cloud-storage[3.0.0, …, 3.0.8] require google/cloud-storage ^1.23 -> satisfiable by google/cloud-storage[v1.23.0, …, v1.26.1].
- google/cloud-storage[v1.25.0, …, v1.26.1] require google/cloud-core ^1.43 -> satisfiable by google/cloud-core[v1.43.0, v1.43.1, v1.43.2, v1.44.0].
- google/cloud-storage[v1.23.0, …, v1.24.1] require google/cloud-core ^1.39 -> satisfiable by google/cloud-core[v1.39.0, …, v1.44.0].
- google/cloud-core[v1.43.0, …, v1.44.0] require google/auth ^1.18 -> satisfiable by google/auth[v1.18.0].
- google/cloud-core[v1.42.0, …, v1.42.2] require google/auth ^1.12 -> satisfiable by google/auth[v1.12.0, …, v1.18.0].
- google/cloud-core[v1.39.0, …, v1.41.1] require google/auth ^1.6 -> satisfiable by google/auth[v1.6.0, …, v1.18.0].
- google/auth[v1.6.0, …, v1.15.2] require psr/cache ^1.0 -> found psr/cache[1.0.0, 1.0.1] but the package is fixed to 3.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.
- google/auth[v1.16.0, …, v1.18.0] require psr/cache ^1.0|².0 -> found psr/cache[1.0.0, 1.0.1, 2.0.0] but the package is fixed to 3.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 league/flysystem-google-cloud-storage ^3.0 -> satisfiable by league/flysystem-google-cloud-storage[3.0.0, 3.0.1, 3.0.2, 3.0.8].
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.

So what’s next? Checking the library’s issues and merge request is definitely the way to go. Is there a chance for it to support psr/cache:^3.0 anytime soon?

According to Brent Shaffer’s merge request it’s being worked on, but not yet done. Let subscribe to the merge request’s notifications (and maybe releases too) until we can upgrade everything.

Shows the option for a custom subscription to Github notifications for pull requests.
Custom subscription to Github notifications for pull requests.

Meanwhile, we aren’t done yet, the boss is still waiting for everything to work! Lets downgrade slightly and precisely. According to the error message, symfony/cache-contracts:^3.0 is the only package requiring psr/cache:^3.0.

composer require symfony/cache-contracts:^2.0
./composer.json has been updated
Running composer update symfony/cache-contracts
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Downgrading symfony/cache-contracts (v3.0.0 => v2.5.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Downgrading symfony/cache-contracts (v3.0.0 => v2.5.0): Extracting archive
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class…composer/package-versions-deprecated: …done generating version class
111 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [OK]
Executing script assets:install public [OK]

We can now downgrade psr/cache, since symfony/cache-contracts allows psr/cache version ^1.0|^2.0|^3.0

composer require psr/cache:^2.0
./composer.json has been updated
Running composer update psr/cache
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Downgrading psr/cache (3.0.0 => 2.0.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Downgrading psr/cache (3.0.0 => 2.0.0): Extracting archive
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class…composer/package-versions-deprecated: …done generating version class
111 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [OK]
Executing script assets:install public [OK]

Finally, we can require our initial package.

composer require league/flysystem-google-cloud-storage:^3.0
./composer.json has been updated
Running composer update league/flysystem-google-cloud-storage
Loading composer repositories with package information
Updating dependencies
Lock file operations: 14 installs, 0 updates, 0 removals
- Locking firebase/php-jwt (v5.5.1)
- Locking google/auth (v1.18.0)
- Locking google/cloud-core (v1.44.0)
- Locking google/cloud-storage (v1.26.1)
- Locking google/crc32 (v0.1.0)
- Locking guzzlehttp/guzzle (7.4.1)
- Locking guzzlehttp/promises (1.5.1)
- Locking guzzlehttp/psr7 (2.1.0)
- Locking league/flysystem-google-cloud-storage (3.0.8)
- Locking psr/http-client (1.0.1)
- Locking psr/http-factory (1.0.1)
- Locking psr/http-message (1.0.1)
- Locking ralouphie/getallheaders (3.0.3)
- Locking rize/uri-template (0.3.4)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 14 installs, 0 updates, 0 removals
- Installing firebase/php-jwt (v5.5.1): Extracting archive
- Installing rize/uri-template (0.3.4): Extracting archive
- Installing psr/http-message (1.0.1): Extracting archive
- Installing ralouphie/getallheaders (3.0.3): Extracting archive
- Installing psr/http-factory (1.0.1): Extracting archive
- Installing guzzlehttp/psr7 (2.1.0): Extracting archive
- Installing guzzlehttp/promises (1.5.1): Extracting archive
- Installing psr/http-client (1.0.1): Extracting archive
- Installing guzzlehttp/guzzle (7.4.1): Extracting archive
- Installing google/auth (v1.18.0): Extracting archive
- Installing google/cloud-core (v1.44.0): Extracting archive
- Installing google/crc32 (v0.1.0): Extracting archive
- Installing google/cloud-storage (v1.26.1): Extracting archive
- Installing league/flysystem-google-cloud-storage (3.0.8): Extracting archive
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class…
composer/package-versions-deprecated: …done generating version class
116 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [OK]
Executing script assets:install public [OK]

Obviously composer outdated won’t be the happier ever… but remember what we supposedly did before, subscribing to notifications to hopefully update all this soon!

--

--

Freelance PHP Developer / Web architect, @scotlandphp organiser | Zend Certified Architect