ugexe / zef

Raku Module Management
Artistic License 2.0
206 stars 44 forks source link

Digest vs Digest::MD5 (advice please) #558

Closed librasteve closed 2 months ago

librasteve commented 2 months ago

Context

I am asking for advice on how to proceed.

tonyo: please can you take a look at this and maybe give us the best route forward (eg. adopt Digest::MD5 as a community module and uber-bump the version??)

zef install Digest::MD5

pulls from Digest

===> Staging Digest:ver<1.1.0>:auth<zef:grondilu>
===> Staging [OK] for Digest:ver<1.1.0>:auth<zef:grondilu>
===> Testing: Digest:ver<1.1.0>:auth<zef:grondilu>
===> Testing [OK] for Digest:ver<1.1.0>:auth<zef:grondilu>
===> Installing: Digest:ver<1.1.0>:auth<zef:grondilu>

this masks the working, but abandoned, Digest::MD5 module (cosimo)

~ > zef install 'Digest::MD5:ver<0.05>'
===> Searching for: Digest::MD5:ver<0.05>
===> Staging Digest::MD5:ver<0.05>
===> Staging [OK] for Digest::MD5:ver<0.05>
===> Testing: Digest::MD5:ver<0.05>
===> Testing [OK] for Digest::MD5:ver<0.05>
===> Installing: Digest::MD5:ver<0.05>

[I gather that this ver<1.1.0> (of the Digest umbrella) trumps the ver<0.05> is desired behaviour]

oddly (to me), Nb. Since commit 911c292688ad056a98285f7930297c5e1aea3bfb, there is no Digest module anymore, the submodules, Digest::MD5, Digest::SHA1 and so on must be used directly.

Expected Behavior

we want the example for the docs (and MD5 in general) to work

Actual Behavior

this example from the raku docs...

use Digest::MD5;
my $password = "password123";
my $hashed-password = Digest::MD5.new.md5_hex($password);

say $hashed-password;

fails with

~/scum > raku scum.raku
You cannot create an instance of this type (Digest::MD5)
  in block <unit> at scum.raku line 4

Steps to Reproduce

follow raku docs example

Your Environment

raku -v

Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2024.04.```

zef list --installed
```===> Found via inst#/Users/xxx/.rakubrew/versions/moar-2024.04/share/perl6/site
App::Crag:ver<0.0.15>:auth<zef:librasteve>:api<1>
AttrX::Lazy:ver<0.0.3>
Chemistry::Stoichiometry:ver<0.1.8>:auth<zef:antononcube>:api<1>
Digest::MD5:ver<0.05>:auth<cosimo>
File::Directory::Tree:ver<0.1>:auth<zef:labster>
File::Find:ver<0.2.1>:auth<zef:raku-community-modules>
File::Temp:ver<0.0.11>:auth<zef:raku-community-modules>
File::Which:ver<1.0.4>
JSON::Class:ver<0.0.21>:auth<zef:jonathanstowe>:api<1.0>
JSON::Fast:ver<0.19>:auth<cpan:TIMOTIMO>
JSON::Marshal:ver<0.0.25>:auth<zef:jonathanstowe>:api<1.0>
JSON::Name:ver<0.0.7>:auth<zef:jonathanstowe>:api<1.0>
JSON::OptIn:ver<0.0.2>:auth<zef:jonathanstowe>
JSON::Unmarshal:ver<0.15>:auth<zef:raku-community-modules>
LibraryMake:ver<1.0.5>:auth<zef:jjmerelo>
License::SPDX:ver<3.23.0>:auth<zef:jonathanstowe>:api<1.0>
Linenoise:ver<0.1.2>:auth<zef:raku-community-modules>
META6:ver<0.0.30>:auth<zef:jonathanstowe>:api<1.0>
MIME::Base64:ver<1.2.3>:auth<zef:raku-community-modules>
Math::Constants:ver<0.2.2>:auth<zef:jjmerelo>
Math::Matrix:ver<0.3.9>:auth<github:pierre-vigier>
Physics::Constants:ver<1.0.3>:auth<zef:librasteve>:api<1>
Physics::Error:ver<0.1.3>:auth<zef:librasteve>:api<1>
Physics::Measure:ver<1.0.20>:auth<zef:librasteve>:api<1>
Physics::Navigation:ver<0.0.3>:auth<zef:librasteve>:api<1>
Physics::Unit:ver<1.1.27>:auth<zef:librasteve>:api<1>
SVG::Plot
SVG:ver<1.0>
Shell::Command:ver<1.1>:auth<zef:raku-community-modules>
Slang::Roman:ver<0.5>:auth<zef:raku-community-modules>
Slang::Tuxic:ver<0.0.4>:auth<zef:raku-community-modules>
Slangify:ver<0.0.3>:auth<zef:lizmat>
Test::META:ver<0.0.20>:auth<zef:jonathanstowe>:api<1.0>
Text::CSV:ver<0.022>:auth<zef:Tux>
Time::Duration::Parser:ver<0.0.3>:auth<zef:raku-community-modules>
URI:ver<0.3.7>:auth<zef:raku-community-modules>
XML::Writer
YAMLish:ver<0.1.1>:auth<zef:leont>
zef:ver<0.21.4>:auth<github:ugexe>:api<0>
ugexe commented 2 months ago

[I gather that this ver<1.1.0> (of the Digest umbrella) trumps the ver<0.05> is desired behaviour]

Digest is chosen because it is in the fez ecosystem, which takes precedence over other ecosystems. If both modules were in the same ecosystem then yes the higher version one would be chosen.

we want the example for the docs (and MD5 in general) to work

Update the example to contain use Digest::MD5:ver<0.05>; (since it does not contain an auth at all) instead, or update it to use Digest.

librasteve commented 2 months ago

forgive me, I had anyway reached the understanding that ver<1.1.0> trumps ver<0.0.5>, not sure what the fez ecosystem has to do with that and found that use Digest::MD5:ver<0.05>; patches the issue

it also shows that pinning is a good idea, but I don't think our docs example should pin to such an old module

then, thanks to you comment .oO the Digest version is failing since these two module authors have chosen different APIs (durrr) - appreciate the guidance

Just need to file a docs issue to use the Digest API going forward

librasteve commented 2 months ago

Actually this issue arose in the rakuguide examples, not raku docs

Here's the fix PR https://github.com/hankache/rakuguide/pull/231

AntonOks commented 2 months ago

[I gather that this ver<1.1.0> (of the Digest umbrella) trumps the ver<0.05> is desired behaviour]

Digest is chosen because it is in the fez ecosystem, which takes precedence over other ecosystems. If both modules were in the same ecosystem then yes the higher version one would be chosen.

How and who takes the choice, what is on which (Raku modules) ecosystem? I'm wondering, because, from my guess, the "untouched-since-7-years" Digest::MD5 should have a lower priority with the relatively new FEZ ecosystem, compared to obviously newer Digest::MD5

we want the example for the docs (and MD5 in general) to work

I guess, the docs example was wrong because someone in the past tried to change it from the older to the newer module, see above. Why do I think so... I haven't seen a md5_hex in the new module?!

Update the example to contain use Digest::MD5:ver<0.05>; (since it does not contain an auth at all) instead, or update it to use Digest.

The new module seems not to offer use Digest anymore, see https://github.com/grondilu/libdigest-raku/blob/master/README.md#synopsis ... so to use it's sub, one has to use the sub-modules, so also use Digest::MD5;

see https://github.com/grondilu/libdigest-raku/issues/40#issuecomment-2091224448 for my other comments, also about ZEFs prios...

ugexe commented 2 months ago

How and who takes the choice, what is on which (Raku modules) ecosystem?

It can be configured in the zef configuration file.

I'm wondering, because, from my guess, the "untouched-since-7-years" Digest::MD5 should have a lower priority with the relatively new FEZ ecosystem, compared to obviously newer Digest::MD5

I don't think I follow you - this is how it already works.

so to use it's sub, one has to use the sub-modules, so also use Digest::MD5;

Right. I didn't say to use Digest;, I said to use Digest