wm1ke has asked for the wisdom of the Perl Monks concerning the following question:

I play with perl and enjoy it but modules and installing them jut do not seem to fit with my old brain. I am trying to install Device::SerialPort on my Ubuntu box. After using cpanm I was told:

Device::SerialPort is up to date.(1.04) mike@BlsckBox:~/ham$

When I try to run the code I get the message :

perl radio.pl Can't locate Device/SerialPort.pm in @INC (you may need +to install the Device::SerialPort module) (@INC contains: /etc/perl / +usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22 +.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86 +_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl + /usr/lib/x86_64-linux-gnu/perl-base .) at radio.pl line 6. BEGIN fai +led--compilation aborted at radio.pl line 6.

Here is the faulting code:

# # Control access to an ICOM radio # use vars qw( $ob $port ); use Device::SerialPort; use sigtrap qw(INT SIGINT); $ob = new Device::SerialPort ("/dev/ttyUSB0", 1);

I get off my wheel chair and knell on the floor before the monks to help an old man who appreciates it.

Replies are listed 'Best First'.
Re: Device::SerialPort Brain Problems
by tybalt89 (Monsignor) on Mar 27, 2017 at 00:52 UTC

    use

    locate SerialPort.pm

    to find out where it actually is (like /somepath/Device/SerialPort.pm ), and then

    use lib '/somepath';

    to allow your program to find it.

Re: Device::SerialPort Brain Problems
by haukex (Archbishop) on Mar 27, 2017 at 08:06 UTC

    Two different installations of Perl perhaps? Try comparing the outputs of the following with the shebang (#!) line at the top of the script.

    $ which cpanm $ which perl $ perl -le 'print $^X'

      As Demonstrated in the code above, I do not list a path to perl in my code, making it a little more portable among all the little cheap devices I play with. The result of the querying was:

      mike@BlsckBox:~/Desktop$ which cpanm /usr/bin/cpanm mike@BlsckBox:~/Desktop$ which perl /usr/bin/perl mike@BlsckBox:~/Desktop$ perl -le 'print $^X' /usr/bin/perl mike@BlsckBox:~/Desktop$

      Thanks for putting up with this old 70s freak.

        Hm, so it looks like you're using the system Perl. I assume your scripts also start with the line "#!/usr/bin/perl"? Then question then is why cpanm Device::SerialPort shows the module is installed. Perhaps you're using a not fully configured local::lib? Did you try looking for the SerialPort.pm file like tybalt89 suggested? Also, if you could show the output of the following commands.

        $ echo $PERL5LIB $ echo $PERL_MB_OPT $ echo $PERL_MM_OPT $ echo $INSTALL_BASE

        Update: I struck the question that I missed your answer to before. Also, I should say that modifying the system Perl with cpan or cpanm is not necessarily recommended, since it's possible for failed module installations to mess up the system Perl and potentially all the system tools that rely on it. It usually is ok to install modules into the system Perl with the system's package manager though, so on Ubuntu you could use sudo apt-get install libdevice-serialport-perl. Either that, or you could use local::lib to install modules in your home directory, or you could even use perlbrew to install your own local copy of Perl that you can install all the modules you like, plus you'd get the newest version of Perl available.

      Surgery This week. Hope I can play with the code next week. Thanks for the help everyone! wm1ke

Re: Device::SerialPort Brain Problems
by dazz (Beadle) on Mar 27, 2017 at 08:11 UTC
    Hi If you run Ubuntu and you are trying to install modules from CPAN, you need to first install build-essential, automake and checkinstall. Only then can you use CPAN.
Re: Device::SerialPort Brain Problems
by Anonymous Monk on Mar 27, 2017 at 00:58 UTC

    What is @INC under cpanm? Why is @INC under cpanm different from your regular @INC?