16

I installed Perl6 with rakudobrew and wanded to browse the installed files to see a list of hex-filenames in ~/.rakudobrew/moar-2018.08/install/share/perl6/site/sources as well as ~/.rakudobrew/moar-2018.08/install/share/perl6/sources/.

E.g.

> ls ~/.rakudobrew/moar-2018.08/install/share/perl6/sources/
09A0291155A88760B69483D7F27D1FBD8A131A35  AAC61C0EC6F88780427830443A057030CAA33846
24DD121B5B4774C04A7084827BFAD92199756E03  C57EBB9F7A3922A4DA48EE8FCF34A4DC55942942
2ACCA56EF5582D3ED623105F00BD76D7449263F7  C712FE6969F786C9380D643DF17E85D06868219E
51E302443A2C8FF185ABC10CA1E5520EFEE885A1  FBA542C3C62C08EB82C1F4D25BE7B4696F41B923
522BE83A1D821D8844E8579B32BA04966BAB7B87  FE7156F9200E802D3DB8FA628CF91AD6B020539B
5DD1D8B49C838828E13504545C427D3D157E56EC

The files contain the source of packages but this does not feel very accessible. What is the rational for that?

Pat
  • 36,282
  • 18
  • 72
  • 87
matthias krull
  • 4,389
  • 3
  • 34
  • 54
  • 2
    See also [The Meta spec, Distribution, and CompUnit::Repository explained-ish](https://perl6advent.wordpress.com/2016/12/16/day-16-the-meta-spec-distribution-and-compunitrepository-explained-ish/) and [How to find all installed modules whose filename matches a pattern?](https://stackoverflow.com/q/37350925/2173773) – Håkon Hægland Oct 02 '18 at 09:59

1 Answers1

15

In Perl 6, the mechanism for loading modules and caching their compilations is pluggable. Rakudo Perl 6 comes with two main mechanisms for this.

One is a file-system based repository, and it's used with things like -Ilib. This resolves modules simply using paths on disk. Whenever a module loaded, it first has to check that the modules sources have not changed in order to re-compile them if so. This is ideal for development, however such checks take time. Furthermore, this doesn't allow for having multiple versions of the same module available and picking the one matching the specification in the use statement. Again, ideal for development, when you just want it to use your latest changes, but less so for installation of modules from the ecosystem.

The other is an installation repository. Here, specific versions of modules are installed and precompiled. It is expected that all interactions with such a repository will be done through the API or tools using the API (for example, zef locate Some::Module). It's assumed that once a specific version of a module has been installed, then it is immutable. Thus, no checks need to be done against source, and it can go straight to loaded the compiled version of the module.

Thus, the installation repository is not intended for direct human consumption. The SHA-1s are primarily an implementation convenience; an alternative scheme could have been used in return for a bit more effort (and may well be used in the future). However, the SHA-1s do also create the appearance of something that wasn't intended for direct manipulation - which is indeed the case: editing a source file in there will have no effect in the immediate, and probably confusing effects next time the compiler is upgraded to a new version.

Jonathan Worthington
  • 29,104
  • 2
  • 97
  • 136
  • 1
    I see. So no more hacking installed modules for quick and easy debugging or exploration :'| but I get the idea. – matthias krull Oct 02 '18 at 13:34
  • 5
    @matthiaskrull That counts as dev. You can just download the modules you're interested in to a directory, say 'lib', and then add `-Ilib` to your command line or `use lib 'lib';` in your code. Perhaps it makes sense for `zef` to have an option for doing the copying if it doesn't already have one. – raiph Oct 02 '18 at 14:03
  • I know, I am just used to the ease of editing away with `Perl`, `Ruby`, `Python` many/most other languages around. – matthias krull Oct 02 '18 at 15:47
  • OOC, do these languages support having modules with the same name, but different versions and/or different authors installed at the same time> – Elizabeth Mattijsen Oct 02 '18 at 16:22
  • Of course not. Actually that depends but without hackery (e.g. different import path makes it a different module) probably not. – matthias krull Oct 02 '18 at 16:26
  • @matthiaskrull Note that not only can there be various different versions installed, they can be loaded into the same process. `{use Foo:auth};{use Foo:auth}` – Brad Gilbert Oct 02 '18 at 18:00
  • 2
    This also allows for a distribution to represent e.g. Foo.pm and foo.pm on a case-insensitive file system. I'm not aware of a human readable way to solve this since almost all module names / file paths have both lower and upper case letters ( meaning in almost all cases the name would need to be mangled ). – ugexe Oct 02 '18 at 18:46
  • 1
    I understand the problem it solves now and can totally accept it. Encountering those file names will still raise eye brows because the rationale is not intuitively clear I think. – matthias krull Oct 03 '18 at 13:57
  • I sometimes wonder if we should store them in a SQLite database instead, so folks don't encounter them. Alas, then we can't `mmap` the precompiled bytecode files. :-) – Jonathan Worthington Oct 03 '18 at 16:51