I’m trying to build a perl program from source. The program has a Build script which installs all the many dependencies by cpan by invoking perl ./Build installdeps
. However, some of the dependencies can’t be installed by cpan properly, namely Wx.
On a fresh install of Ubuntu 22.04, I’ve been able to workaround this by installing the necessary modules via apt. For Wx, for example, I can do sudo apt install libalien-wxwidgets-perl libwx-perl
and then if I run perl ./Build installdeps
or simply cpan -i Wx
, cpan detects that Wx is already installed, and I can eventually run ./Build install
and the program will work with the dependencies installed by apt. But, on my main computer, I’m unable to do this. I can install all the same dependencies by apt, but cpan still thinks they’re not installed
2
Answers
You need to tell Perl where to look for modules if they are outside the default set of module search paths. Run
perl -V
to see what’s in @INC by default:I’m guessing that the two systems in your question are configured differently for this. Look at all the environment variables that start with
PERL
and compare the lists.If your modules are somewhere else, you need to include those directories in
@INC
. See How do I add a directory to my include path (@INC) at runtime? in perlfaq8.sudo apt install libalien-wxwidgets-perl
will install the module for the systemperl
. This is not what you intend to do. From the comments you posted and the behaviour you describe, I gather you want to install the module for a differentperl
. This is usually done usingNote that you need to use the
cpan
that was installed by the relevantperl
. That’s how it knows for whichperl
to install the module, so to speak. Use the full path if necessary. That said, it sounds like you are using the correctcpan
, so this paragraph isn’t applicable to you.Now, you say
cpan Alien::wxWidgets
doesn’t work for you. That may be, but that’s a problem you’ll need to address directly, not by installing the module using a differentperl
. Oneperl
can’t use a module built by a differentperl
.[1]perl
on the same system.