6

I'd like to be able to view and make changes to the source code of installed (via zef) perl6 modules. How can I do that?

On my system, the module sources are under ~/.perl6/sources/ and there's also some kind of metadata file about the modules in ~/.perl6/dist/.

I can also use zef locate ... to show a module's source path, but making changes directly to the source files doesn't seem to have any effects (i.e., use the module from the REPL doesn't show my changes).

I'm guessing it's because the modules were pre-compiled, and perl6 doesn't pick up my changes and re-precompile the modules when I make changes directly to the module source files that way...

UPDATE: Deleting the corresponding pre-compiled files under ~/.perl6/precomp/... seems to work, but I'm not sure how and if that messes up anything.

jjmerelo
  • 22,578
  • 8
  • 40
  • 86
cowbaymoo
  • 1,202
  • 5
  • 14
  • 2
    See also [How can I rebuild an edited perl6 module that I've downloaded?](https://stackoverflow.com/q/54023388/2173773) and [How to edit the source code in module after installed it using zef?](https://stackoverflow.com/q/50264214/2173773) – Håkon Hægland May 10 '19 at 20:29
  • 1
    sigh, I guess that answered my question. I'll give it a try and see if it fits my workflow. Thanks. – cowbaymoo May 10 '19 at 20:50
  • 1
    Maybe you like to change the include path with `PERL6LIB` env variable or with `perl6 -I` (see perl6 --help for both options). The is also `use lib` pragma. When to use what and how it does affect precompile my be enough for a separate question. – LuVa May 10 '19 at 21:09
  • My attempts to find a similar SO fail, despite knowing of the existence of the ones Håkon linked. If that's why you wrote "sigh" it might be worth mentioning somewhere on meta.stackoverflow.com. – raiph May 11 '19 at 10:20
  • 1
    I didn't find the existing answers (as suggested by Håkon) earlier when I googled, and also SO failed to suggest them when I was writing the question. Otherwise, yeah, this question is basically a duplicate..., and I think the existing answers already answer my question. The only value I can think of for my question is that it might now make it a bit easier for other people to find similar questions before posting their own. – cowbaymoo May 12 '19 at 04:14

1 Answers1

9

I'd like to be able to view and make changes to the source code of installed (via zef) perl6 modules. How can I do that?

Please, don't do it that way. Installed modules are supposed to be immutable and as you've found out: if there is a pre-compiled version of a module available, it will not check if the original source file has been updated. That's because it doesn't have to, because it is considered immutable.

If you want to test changes on an installed module, please download the tar file / git clone the module's distribution, make changes you need in there, and then do:

zef install . --force-install

while in the top directory in the distribution. That will re-install the module and handle pre-compilation for you.

Elizabeth Mattijsen
  • 25,654
  • 3
  • 75
  • 105
  • NOTE: I found that `zef` places the module source distributions (as git repos or unpacked tar.gz files) of installed modules under `~/.zef/store/`. Also, `zef fetch ...` unpacks the dists there. You can also use `zef look ...` to `zef fetch` and then shell into the directory for you. (this is one extra level of shell though). – cowbaymoo May 11 '19 at 01:24
  • 1
    And all of this can be changed without notice, as these are undocumented internal workings. So YMMV. – Elizabeth Mattijsen May 11 '19 at 06:00
  • Hi @cowbaymoo. I'm curious whether you see the advantages in theory of distinguishing between modules that are presumed mutable (changeable/editable) vs presumed immutable? And aligning that distinction with the process of installation (so a module that's just a file on disk is presumed mutable but one that's been formally installed is presumed immutable)? More practically, presuming you've gotten used to the one-two step `zef look...`, `zef install...`, does this workflow feel about right to you (ignoring the double shell)? – raiph May 11 '19 at 10:31
  • Coming from python and ruby, I'm used to mutable modules/packages, and the fact that usually it's very easy to map from a module used in a program to its source file in the file system. But I do see the advantages with installed, immutable modules and why perl 6 needed to use the not so straightforward way of naming installed modules (so that unicode module name can be supported on all file systems, if I remember correctly). `zef look ...` doesn't seem to git clone the repo of the module so I'll have to work around that. – cowbaymoo May 12 '19 at 04:08