I have packaged my app as a Perl module, which fails to install using the cpan
or cpanm
commands. The problem is that these commands - when not run as root - install the prerequisite modules into the ~/perl5 directory. However, my ~/perl5 directory is not included in the @INC
This leads to the following confusing output from cpanm:
$ cpanm --installdeps .
--> Working on .
Configuring my-module-0.001 ... OK
==> Found dependencies: Image::Size
--> Working on Image::Size
Fetching http://www.cpan.org/authors/id/R/RJ/RJRAY/Image-Size-3.232.tar.gz ... OK
Configuring Image-Size-3.232 ... OK
Building and testing Image-Size-3.232 ... OK
Successfully installed Image-Size-3.232
! Installing the dependencies failed: Module 'Image::Size' is not installed
! Bailing out the installation for my-module-0.001.
1 distribution installed
As you can see, it successfully downloads, tests and installs the Image::Size module, but then tries to use it and fails.
I know I can fix this problem by setting the environment variable $PERL5LIB to "~/perl5/lib/perl5" and adding "~/perl5/bin" to my $PATH, but I'd really like to know how this situation arose in the first place. I would like to keep the installation instructions for my app's users as simple as possible, and manually modifying environment variables is not something I plan to instruct them.
If you're using bash, you could install local::lib add something like this to your .bashrc file
That should solve your problem. The issue is the way your local system is configured, so tweak that rather than bringing Dist::Zilla into the mix where it's not required.