【问题标题】:Could not find File::Find Raku on Windows 7在 Windows 7 上找不到 File::Find Raku
【发布时间】:2021-03-14 17:41:27
【问题描述】:

我有一个非常简单的程序,它列出了给定目录中的所有.txt 文件。该程序在我的 Rakudo Star 版本 2019.03.1 的 Mac 上完美运行

use File::Find;

my $folder="../Documents";

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

当我尝试在具有 Raku 2020.12.1 的 Windows 7 上运行相同的程序时,它给出了:

$ 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

我已将 Raku 更新到 Raku 2021.02.1 版本,但又出现了同样的错误。我通过解压缩rakudo-moar-2021.02.1-01-win-x86_64-msvc.zip 安装它,即不使用任何安装程序。至于 Mac 上的 Raku,我不记得安装了 File::Find 模块,也不知道如何列出已安装的模块,即我没有检查 File::Find 是否安装在 Mac 或 Windows 7 上。

如何让这个程序在 Windows 7 上运行?

【问题讨论】:

  • 您的脚本是否可能包含特定于 Mac 的斜线目录地址?在 Windows 上无法正确读取的内容?此行出现异常:C:\Users\lars\raku/html-adder.rk
  • @jubilatious1 不,这与使用正斜杠或反斜杠无关。无论如何,该行是编译器输出的,所以它一定是正确的。如今,编译器包含正斜杠和反斜杠的行并不少见。

标签: module raku rakudo


【解决方案1】:

File::Find 没有内置在 Raku 中,也没有与 Rakudo Star 一起分发;据我所知,从来没有。

它是一个module in the ecosystem,您可以使用 Zef 安装(使用命令 zef install File::Find)。

它也是一个很短的库。如果您有兴趣在不添加依赖项的情况下修复脚本,您可能需要查看 the source code 的 File::Find;它足够短,您可以轻松地自己实现相同的功能。

【讨论】:

  • 它工作,通过使用选项--force-test。棘手的部分是现在,它是如何在 Mac 上工作的。我浏览了~/.bash_history,在大约 16.000 个条目中,没有一行包含 zef install File::Find 就像一个谜题:)
  • @LarsMalmsteen 可能是在安装其他模块时安装了 zef。它会自动为你安装依赖项。
  • @LarsMalmsteen 也许您安装的 Mac 软件包安装了 File::Find,但普通的 Windows 没有。 zef list --installed 列出了什么?点击link to an online evaluator which predetermines what packages are installed。我得到===> Found via /opt/rakudo-pkg/share/perl6/core ===> Found via /opt/rakudo-pkg/share/perl6/site (CORE:ver<6.d>:auth<perl> zef:ver<0.9.4>:auth<github:ugexe>:api<0> File::Find:ver<0.1.1> File::Which:ver<1.0.1> LibraryMake:ver<1.0.0>:auth<github:retupmoca> Linenoise:ver<0.1.1>:auth<Rob Hoelz> Shell::Command)
  • 跟进@user0721090601 的观点,看起来File::Find8th most frequent direct dependency(也是第24 个最常见的及物)。因此,将它安装为其他东西的依赖项似乎是一个不错的选择。
  • @raiph zef list --installed 给出了大约 30 行模块名称,其中当然列出了 File::Find。使用 zef 仅安装了 3 个模块,它们是 Colorperl6-colorTerminal-ANSIcolor 因为在 .bash_history 中只能找到这 3 个模块,顺便说一句,还有另一个问题:File::Find 打印非包含 ASCII 字符的文件名不正确。如果我无法修复它,我可能不得不发布一个关于它的新 Q。
猜你喜欢
  • 2013-06-08
  • 2016-05-31
  • 1970-01-01
  • 2015-01-16
  • 2011-06-23
  • 1970-01-01
  • 1970-01-01
  • 2013-01-13
  • 1970-01-01
相关资源
最近更新 更多