php bin/magento setup:upgrade issue

The fix for the issue -

Type Error occurred when creating the object: Magento\Framework\Locale\Resolver

is not modifying the core class at all. We need to understand the cause of it first. Modifying the core class is not recommended at all. The issue is not with the class vendor/magento/framework/Encryption/Adapter/SodiumChachaIetf.php

⚠️ But the issue with the crypt key added to your app/etc/env.php

The reason for this issue is the crypt key is mismatched. You must have taken the database dump from any other instance and trying to run with your current instance. So along with the database, you need to get the crypt key from the same setup where from you got the DB dump.

Just update the crypt key in env.php and it will work fine.

The fix is to use the same pair of crypt keys of the installation from where DB is being used.

Hope it is explained.

Mark me up if was helpful. Happy coding..!!


I have searched around and found this solution this is because of return $plainText SodiumChachaIetf::decrypt() must be of the type string, boolean

Go to this file:

vendor/magento/framework/Encryption/Adapter/SodiumChachaIetf.php

And Update Below Code:

$plainText = sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
            $payload,
            $nonce,
            $nonce,
            $this->key
        );
        if ($plainText == false)
        {
          return "";
        }
        return $plainText;