9

I've got a very simple program which lists all .txt files in a given directory. This program has run perfectly on my Mac which has the Rakudo Star version 2019.03.1

use File::Find;

my $folder="../Documents";

.say for find dir => $folder, name => /'.txt' $/;

When I've tried to run the same program on Windows 7 which had Raku 2020.12.1 it gave this:

$ raku html-adder.rk

===SORRY!=== Error while compiling C:\Users\lars\raku/html-adder.rk

Could not find File::Find in:
    inst#C:\Users\lars\.raku
    inst#C:\Programs\rakudo-moar-2021.02.1\share\perl6\site
    inst#C:\Programs\rakudo-moar-2021.02.1\share\perl6\vendor
    inst#C:\Programs\rakudo-moar-2021.02.1\share\perl6\core
    ap#
    nqp#
    perl5#
at C:\Users\lars\raku/html-adder.rk:12

I've updated the Raku to version Raku 2021.02.1 and the same error again. I've installed it by unzipping the rakudo-moar-2021.02.1-01-win-x86_64-msvc.zip i.e. without using any installer. And as regards to the Raku on Mac, I don't remember installing the File::Find module, nor do I know how to list the installed modules, i.e. I haven't checked if File::Find was installed on Mac or Windows 7.

How to make this program work on Windows 7?

Lars Malmsteen
  • 738
  • 4
  • 23
  • Does your script perhaps contain a Mac-specific slashed directory address? One that doesn't get read properly on Windows? This line appears unusual: `C:\Users\lars\raku/html-adder.rk` . – jubilatious1 Mar 15 '21 at 14:54
  • @jubilatious1 no it's not really about the use of forward or back slashes.That line was output by the compiler anyway so it's bound to be correct. It's not uncommon for a compiler these days to have lines which contain both forward and back slashes. – Lars Malmsteen Mar 16 '21 at 08:46

1 Answers1

8

File::Find is not built into Raku or distributed with Rakudo Star; to my knowledge, it never has been.

It is a module in the ecosystem that you can install with Zef (use the command zef install File::Find).

It is also a very short library. If you are interested in fixing your script without adding a dependency, you may want to check out the source code for File::Find; it is short enough that you could easily implement the same functionality yourself.

codesections
  • 8,900
  • 16
  • 50
  • 1
    It worked,by using the option `--force-test`. The tricky part is now, how it worked on Mac. I've browsed the `~/.bash_history` and among the 16.000 entries or so, there was no line containing `zef install File::Find` Like a puzzle :) – Lars Malmsteen Mar 14 '21 at 19:41
  • 2
    @LarsMalmsteen it may be that zef installed while installing some other module. It will automatically install dependencies for you. – user0721090601 Mar 14 '21 at 20:22
  • 1
    @LarsMalmsteen Maybe the Mac package you installed installs `File::Find` but the stock Windows one doesn't. What does `zef list --installed` list? Click [link to an online evaluator which predetermines what packages are installed](https://replit.com/@RalphMellor/zef-list-installed). I get `===> Found via /opt/rakudo-pkg/share/perl6/core ===> Found via /opt/rakudo-pkg/share/perl6/site (CORE:ver<6.d>:auth zef:ver<0.9.4>:auth:api<0> File::Find:ver<0.1.1> File::Which:ver<1.0.1> LibraryMake:ver<1.0.0>:auth Linenoise:ver<0.1.1>:auth Shell::Command)`. – raiph Mar 14 '21 at 20:38
  • 1
    Following up on @user0721090601's point, it looks like `File::Find` is the [8th most frequent direct dependency](https://finanalyst.github.io/ModuleCitation/#definitions) (and the 24th most common transitive one). So having installed it as a dependency for something else seems like a pretty good bet. – codesections Mar 14 '21 at 20:40
  • @raiph `zef list --installed` gives about 30 lines of module names among which `File::Find` is listed of course. There are only 3 modules installed using the `zef` and they are `Color` , `perl6-color` and `Terminal-ANSIcolor` because only those 3 are to be found in `.bash_history` Btw, there's another problem: `File::Find` prints the non-ASCII character-containing file names incorrectly. If I can't fix it I may have to post a new Q about it. – Lars Malmsteen Mar 14 '21 at 21:10
  • @LarsMalmsteen "Btw, there's another problem" From a Windows specific Q [How to handle special characters ...](https://stackoverflow.com/a/55198087/1077672) "Fortunately Microsoft is now getting with the program and so we may be able find a way to get around problems you have with Unicode on Windows provided you are patient. In particular, if you are using an older Windows version, please expect it to not work at first with modern Unicode aware software unless you are lucky. We'll still help if we can, but it'll likely involve you being patient with us and Microsoft and Rakudo and vice-versa." – raiph Mar 16 '21 at 12:49