Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing perl modules in [Windows Subsystem for Linux]

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.

like image 805
Vasily A Avatar asked Dec 16 '16 16:12

Vasily A


2 Answers

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.

like image 51
ikegami Avatar answered Oct 09 '22 20:10

ikegami


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)"

like image 28
Vasily A Avatar answered Oct 09 '22 19:10

Vasily A