在[Windows Subsystem for Linux]中安装perl模块

Vas*_*y A 5 linux perl windows-10 windows-subsystem-for-linux

我想在Windows 10(WSL)下的Linux环境中使用Perl脚本.我启用了WSL,安装了编译器(gccmake),执行了sudo apt-get install build-essential.Perl正在工作,我可以运行简单的脚本.我尝试安装perl模块时出现问题.例如,我试图LWP通过运行添加perl -MCPAN -e'install "LWP"'.它提供了许多错误/警告消息,从...开始Warning: the following files are missing in your kit:.完整的输出太大了,不能粘贴在这里,所以我必须把它放在别处:http://pastebin.com/RRRedwbG.简而言之,无论是什么包,所有的.pm和.t文件都被认为是丢失的.

ike*_*ami 7

在unix文件系统上,目录.是自身的硬链接,目录..是其父目录的硬链接.所以当你stat是一个目录时,返回的链接数stat至少是1 (name) + 1 (.) + $num_sub_dirs (..).

$ ls -ld .
drwx------ 5 ikegami ikegami 46 Dec 16 12:03 .    # 5 = Could have up to three subdirs

$ ls -l .
total 0
drwx------ 2 ikegami ikegami 10 Dec 16 12:03 a    # 2 = No subdirs
drwx------ 3 ikegami ikegami 24 Dec 16 12:03 b    # 3 = Could have up to one subdir
drwx------ 2 ikegami ikegami 10 Dec 16 12:03 c    # 2 = No subdirs
Run Code Online (Sandbox Code Playgroud)

File :: Find依赖于该信息以在可能的情况下优化自身.

Perl和File :: Find知道FAT和NTFS文件系统不是这种情况,因此在Windows上禁用了优化.但是,VSL看起来像Linux系统,因此他们错误地认为他们正在处理unix文件系统.

最好的解决方法是编辑由以下命令的输出命名的文件:

perl -MConfig -e'CORE::say $INC{"Config.pm"}'
Run Code Online (Sandbox Code Playgroud)

更改

dont_use_nlink => undef
Run Code Online (Sandbox Code Playgroud)

dont_use_nlink => 1
Run Code Online (Sandbox Code Playgroud)

您可以使用验证更改

$ perl -V:dont_use_nlink
dont_use_nlink='1';
Run Code Online (Sandbox Code Playgroud)

这个答案是基于这个错误报告.


Vas*_*y A 5

github.com/Microsoft/BashOnWindows/issues/186上找到解决方案:
1.运行sudo apt-get install liblocal-lib-perl cpanminus build-essential
2.编辑/usr/lib/perl/5.18.2/Config.pm(第94行)以获得dont_use_nlink => 1
3.eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"

  • 第三个命令是使用local :: lib,这与手头的问题无关. (2认同)