Framework: Laravel 5.6 Ramsey UUIds Exception

Created on 25 Feb 2018  路  14Comments  路  Source: laravel/framework

  • Windows x64 running Homestead
  • Laravel Version: 5.6
  • PHP Version: 7.2.0

Description:

On a fresh Laravel 5.6 install when using Str::orderedUuid(); an exception is thrown with the following message

Ramsey\Uuid\Exception\UnsatisfiedDependencyException with message 'Cannot call Ramsey\Uuid\Converter\Number\DegradedNumberConverter::toHex without support for large integers, since integer is an unsigned 128-bit integer; Moontoast\Math\BigNumber is required. '

Steps To Reproduce:

  1. Create a new project
  2. open tinker
  3. call Illuminate\Support\Str::orderedUuid();

Fix:

require suggested dependency Moontoast\Math\BigNumber by doing composer require "moontoast/math" and the error is gone

Please include this package as a dependency if is required to use the new Str function

GL

Most helpful comment

Fresh Laravel 5.6.14 version - same error when trying to call Str::orderedUuid().

All 14 comments

The moontoast/math package is already present as a development package (require-dev). Are we sure that there's no conflicts in any production by moving it up to a normal require?

Hmm - I seem to have the same issue - it's the first time I've decided to use Str::orderedUuid() and was greeted with the exact same error. Has it been resolved?

Fresh Laravel 5.6.14 version - same error when trying to call Str::orderedUuid().

@themsaid @taylorotwell
Please is there any reason why moontoast/math shouldn't be moved from require-dev to require.
I experienced same issue and I'm about using the fix above.
Thanks.

@s-okubanjo It requires an unusual extension in my opinion:

  • moontoast/math 1.1.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
"require": {
        "php": ">=7.1.3",
        "ext-bcmath": "*",
         ...

That would cause conflicts of use for people who will never use Str :: orderedUuid ()

it's just an opinion

It's not an unusual extension if you use Laravel - according to the documentation bcmath has been a required extension since version 5.7.

This package is now abandoned - they suggest using brick/math instead, but after replacing it we're back to:

Ramsey\Uuid\Exception\UnsatisfiedDependencyException: Cannot call Ramsey\Uuid\Converter\Number\DegradedNumberConverter::toHex without support for large integers, since integer is an unsigned 128-bit integer; Moontoast\Math\BigNumber is required.

https://packagist.org/packages/moontoast/math

@sebastiansulinski, sorry about that. brick/math is not a drop-in replacement for moontoast/math in ramsey/uuid. For the 3.x series of ramsey/uuid, you may continue to use moontoast/math. It's not going anywhere鈥攊t just won't get anymore updates or features. Version 4.x of ramsey/uuid (alpha version coming soon 馃) gets rid of the need for moontoast/math.

I do think I see the problem, though...

Laravel uses the CombGenerator to generate bytes for UUIDs, and the CombGenerator calls the toHex() method on the number converter, here: https://github.com/ramsey/uuid/blob/35cf50d7b408fdfc2bc78508a0dafe1778b90354/src/Generator/CombGenerator.php#L75

On 32-bit systems, this won't work without installing moontoast/math. When running on a 32-bit system, ramsey/uuid will automatically select the DegradedNumberConverter, since it can't handle the larger integers (since UUIDs are 128-bit unsigned integers, there is some functionality that can't even work on 64-bit systems without moontoast/math). In your case, doing composer require moontoast/math will fix the issue.

Again, ramsey/uuid 4.x won't have this issue. 馃榾

Thanks @ramsey.

@ramsey are you going to release 4.x before the end of February? If so we could look at making it the new minimum version for Laravel 7.

@driesvints - if you do, could you also adapt vlucas/phpdotenv v4?

@driesvints, yes! I'd like to get an alpha version out soon so folks can test it and make sure it doesn't break everything. I've already got a test that ensures that I don't break Laravel. :-)

https://github.com/ramsey/uuid/blob/eb1645bc7226d41096f5c77e1e67a48e1d09c4df/tests/ExpectedBehaviorTest.php#L591-L624

@ramsey awesome :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PhiloNL picture PhiloNL  路  3Comments

iivanov2 picture iivanov2  路  3Comments

digirew picture digirew  路  3Comments

gabriellimo picture gabriellimo  路  3Comments

shopblocks picture shopblocks  路  3Comments