在 [Windows 子系统中为 Linux] 安装 perl 模块
Installing perl modules in [Windows Subsystem for Linux]
我想在Windows10(WSL). I have enabled WSL, installed compilers (gcc
and make
), executed sudo apt-get install build-essential
. Perl is working and I can run simple scripts. Problems start when I try to install a perl module. For example, I was trying to add LWP
by running perl -MCPAN -e'install "LWP"'
. It gives lots of error/warning messages, starting with Warning: the following files are missing in your kit:
. The full output is too big to paste it here, so I have to put it elsewhere: http://pastebin.com/RRRedwbG下的Linux环境下使用一个Perl脚本。总之,不管是什么包,所有的.pm和.t文件视为丢失。
在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)"
在 unix 文件系统上,目录的 .
对其自身是硬 link,而目录的 ..
是其父目录的硬link。因此,当您 stat
目录时, stat
返回的 link 计数将至少为 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
File::Find 依靠该信息尽可能优化自身。
Perl 和 File::Find 知道 FAT 和 NTFS 文件系统不是这种情况,因此在 Windows 上禁用了优化。然而,VSL 对他们来说看起来像一个 Linux 系统,所以他们错误地认为他们正在处理一个 unix 文件系统。
最好的解决方法是编辑由以下命令的输出命名的文件:
perl -MConfig -e'CORE::say $INC{"Config.pm"}'
改变
dont_use_nlink => undef
至
dont_use_nlink => 1
您可以使用
验证更改
$ perl -V:dont_use_nlink
dont_use_nlink='1';
此答案基于 this bug report。
我想在Windows10(WSL). I have enabled WSL, installed compilers (gcc
and make
), executed sudo apt-get install build-essential
. Perl is working and I can run simple scripts. Problems start when I try to install a perl module. For example, I was trying to add LWP
by running perl -MCPAN -e'install "LWP"'
. It gives lots of error/warning messages, starting with Warning: the following files are missing in your kit:
. The full output is too big to paste it here, so I have to put it elsewhere: http://pastebin.com/RRRedwbG下的Linux环境下使用一个Perl脚本。总之,不管是什么包,所有的.pm和.t文件视为丢失。
在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)"
在 unix 文件系统上,目录的 .
对其自身是硬 link,而目录的 ..
是其父目录的硬link。因此,当您 stat
目录时, stat
返回的 link 计数将至少为 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
File::Find 依靠该信息尽可能优化自身。
Perl 和 File::Find 知道 FAT 和 NTFS 文件系统不是这种情况,因此在 Windows 上禁用了优化。然而,VSL 对他们来说看起来像一个 Linux 系统,所以他们错误地认为他们正在处理一个 unix 文件系统。
最好的解决方法是编辑由以下命令的输出命名的文件:
perl -MConfig -e'CORE::say $INC{"Config.pm"}'
改变
dont_use_nlink => undef
至
dont_use_nlink => 1
您可以使用
验证更改$ perl -V:dont_use_nlink
dont_use_nlink='1';
此答案基于 this bug report。