无法在 Perl 5.32.0 MacOS Sierra 上安装 Test::File

Cannot install Test::File on Perl 5.32.0 MacOS Sierra

我正在尝试在我的 perlbrew 5.32.0 上安装 DateTime,但对其依赖项 Test::File 的测试失败了。重要部分如下:

t/owner.t ..................... # File [blib] belongs to 703404669 (729761796), not 703404669 (703404669)!
t/owner.t ..................... 1/? 
#   Failed test 'owner_is with text username'
#   at t/owner.t line 99.

#   Failed test 'Intentional owner_isnt failure'
#   at t/owner.t line 146.
# STDOUT is:
# > ok 1 - blib doesn't belong to 703404669
# not:
# > not ok 1 - blib doesn't belong to 703404669
# as expected
# STDERR is:
# > 
# > 
# > 
# not:
# > # File [blib] belongs to 703404669 (729761796)!
# > #   Failed test 'blib doesn't belong to 703404669'
# > #   at t/owner.t line 145.

我之前遇到过类似的错误,但是我的 ~/.cpan 目录中几乎每个包都有一个 blib,所以我不确定 cpan 指的是哪个目录。

我的 OS 是 MacOS Sierra 10.12.6 (16G2136)

如何解决这些错误以安装 DateTime

tl;dr:您在依赖项中发现了一个错误。它仅用于测试。您可以忽略失败的测试,强制安装 Test::File,然后继续安装 DateTime。

cpan -f -i Test::File
cpan DateTime
# File [blib] belongs to 703404669 (729761796), not 703404669 (703404669)!

问题是您的用户名是一个数字,Test::File 似乎没有考虑到这一点。

owner_is 检查文件是否为给定用户所有。它接受用户名或数字用户 ID。如果给它一个数字,它 assumes it's a numeric ID。如果 703404669 是您的用户名,它会混淆并将其用作用户 ID。你的用户id真的是729761796. 703404669 != 729761796.

Test::File 可以通过先用 getpwuid and/or 检查 getpwnam 进行验证来防止这种歧义。

恭喜,您在 Test::File 中发现了一个错误。 Please report it.