perlcpan

perl can't find modules installed by apt


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


Solution

  • sudo apt install libalien-wxwidgets-perl will install the module for the system perl. 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 different perl. This is usually done using

    cpan Alien::wxWidgets
    

    Note that you need to use the cpan that was installed by the relevant perl. That's how it knows for which perl to install the module, so to speak. Use the full path if necessary. That said, it sounds like you are using the correct cpan, 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 different perl. One perl can't use a module built by a different perl.[1]


    1. Unless they are sufficiently similar, including but not limited to same version and same or newer revision. But that's surely not the case here. Why would you have two identical perl on the same system.