I would like to use a Perl script in Linux environment under Windows 10 (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. In short, no matter the package, all the .pm and .t files are deemed to be missing.
On unix file systems, a directory's .
is a hardlink to itself, and a directory's ..
is a hardlink to its parent directory. So when you stat
a directory, the link count returned by stat
will be at least 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 relies on that information to optimize itself when possible.
Perl and File::Find know this isn't the case for the FAT and NTFS file systems, so the optimization is disabled on Windows. However, VSL looks like a Linux system to them, so they incorrectly assume they are dealing with a unix file system.
The best fix is to edit the file named by the output of the following command:
perl -MConfig -e'CORE::say $INC{"Config.pm"}'
Change
dont_use_nlink => undef
to
dont_use_nlink => 1
You can verify the change using
$ perl -V:dont_use_nlink
dont_use_nlink='1';
This answer is based on this bug report.
The solution found at github.com/Microsoft/BashOnWindows/issues/186:
1. run sudo apt-get install liblocal-lib-perl cpanminus build-essential
2. edit /usr/lib/perl/5.18.2/Config.pm
(around line 94) to have dont_use_nlink => 1
3. eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With