Avoid Guzzle 6.5.0 (aka How to fix “Use of undefined constant INTL_IDNA_VARIANT_UTS46” on CentOS 6)

There’s a bug in Guzzle 6.5.0 in which it does not play nice with systems that have an older ICU library (which PHP’s Intl extension uses). CentOS 6 for example ships with a very old ICU version, without any (offical) means of updating it. The bug should be fixed in (the unreleased) Guzzle 6.5.1.

It is recommended that all PHP projects avoid Guzzle 6.5.0, by requiring Guzzle as follows:

composer require guzzlehttp/guzzle:'>=6.3.0 <6.5.0 || ^6.5.1'

~

A client of mine reported that he could no longer upload photos to an S3 bucket from within his CraftCMS website. The upload failed with the following message:

Use of undefined constant INTL_IDNA_VARIANT_UTS46 - assumed 'INTL_IDNA_VARIANT_UTS46'

As I had just updated the dependencies of that project, I checked the diff of the composer.json and saw that Guzzle got bumped to version 6.5.0

~

Although the release notes for 6.5.0 somehow don't mention it, there's a commit in 6.5.0 that reads “Internationalized domain name (IDN) support (#2286)”. In that commit you can find usage of PHP's INTL_IDNA_VARIANT_UTS46 constant.

Checking the list of Intl provided constants, there's this small note next to INTL_IDNA_VARIANT_UTS46:

Available as of ICU 4.6.

And, as it turns out, the installed version on the CentOS 6 server that serves the project is lower than 4.6:

$ yum list installed icu
…
Installed Packages
icu.x86_64              4.2.1-14.el6

Unfortunately there's no official way of updating ICU to a more recent version on CentOS 6 (*), so a fix needs to happen on Guzzle's end. An issue has been reported with Guzzle and the fix should land in version 6.5.1.

💁‍♂️ (*) You could try installing this unofficial ICU release from the Remi Repository, but then you'd also need to recompile PHP. This isn't always possible to do – e.g. in cases where it's not your server – and would take us way off.

~

If you – as a PHP developer – are affected by this issue right now, you can work around it by avoiding Guzzle 6.5.0. To do so, require Guzzle as follows:

composer require guzzlehttp/guzzle:'>=6.3.0 <6.5.0 || ^6.5.1'

If you've developed a project which relies on Guzzle, it's recommended to implement this change, just like CraftCMS does, so that your users – who might be running CentOS 6 – are not affected by it.

~

Did this help you out? Like what you see?
Thank me with a coffee.

I don\'t do this for profit but a small one-time donation would surely put a smile on my face. Thanks!

BuymeaCoffee (€4)

To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Unless noted otherwise, the contents of this post are licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT License

Join the Conversation

4 Comments

    1. You’re welcome! Today version 6.5.1 of Guzzle got released, so hopefully not too many folks will get version 6.5.0 anymore.

      Thanks for your donation to, it is appreciated 🙂

      1. When I run this command:
        composer require guzzlehttp/guzzle:’>=6.3.0 <6.5.0 || ^6.5.1'
        I am getting this error:
        The system cannot find the file specified.
        '6.5.1'' is not recognized as an internal or external command, operable program or batch file.

        What should I do, please help me

        1. Works fine here:

          $ composer require guzzlehttp/guzzle:'>=6.3.0 <6.5.0 || ^6.5.1'
          ./composer.json has been updated
          Loading composer repositories with package information
          Updating dependencies (including require-dev)
          Package operations: 5 installs, 0 updates, 0 removals
            - Installing ralouphie/getallheaders (3.0.3): Loading from cache
            - Installing psr/http-message (1.0.1): Loading from cache
            - Installing guzzlehttp/psr7 (1.6.1): Loading from cache
            - Installing guzzlehttp/promises (v1.3.1): Loading from cache
            - Installing guzzlehttp/guzzle (6.5.2): Downloading (100%)         
          guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
          guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
          Writing lock file
          Generating autoload files

          You could try replacing the single quotes by double quotes.

Leave a comment

Leave a Reply to Bramus! Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.