2

I am a new perlbrew user, as I wish to upgrade to perl 5.30.0 on Ubuntu.

I have done

perlbrew init
perlbrew install perl-5.30.0
perlbrew switch perl-5.30.0

so I try to run this test script:

#!/usr/bin/env perl

use strict;
use warnings FATAL => 'all';
use feature 'say';
use autodie ':all';

but this gives the long error

IPC::System::Simple required for Fatalised/autodying system() at /home/con/Scripts/say.pl line 6.
    main::BEGIN() called at /home/con/Scripts/say.pl line 6
    eval {...} called at /home/con/Scripts/say.pl line 6
BEGIN failed--compilation aborted at /home/con/Scripts/say.pl line 6.
Command exited with non-zero status 2

I thought that libraries (especially standard ones) were supposed to be loaded automatically via perlbrew? How can I get this simple script to run?

con
  • 5,767
  • 8
  • 33
  • 62
  • Very curious. I get the same on perlbrew managed v5.29.2 (which otherwise works as expected) – zdim Aug 01 '19 at 17:03

3 Answers3

2

From autodie we see that it's documented behavior

If system is specified as an argument to autodie, then it uses IPC::System::Simple to do the heavy lifting. See the description of that module for more information.

So one does need IPC::System::Simple installed for :all tag (which implies system).

It strikes me as curious that a core functionality requires a non-core module, and quietly too (doesn't complain at installation).

zdim
  • 64,580
  • 5
  • 52
  • 81
1

I'm getting exactly the same error on a non-perlbrew Perl. It seems autodie requires IPC::System::Simple when running under fatal warnings or with :all, but it doesn't require it during installation.

See also https://bugzilla.redhat.com/show_bug.cgi?id=1183231.

choroba
  • 231,213
  • 25
  • 204
  • 289
  • so how should I alter my script so I can `use autodie ':all'`? – con Aug 01 '19 at 17:13
  • Add `use IPC::System::Simple` and install it for all the perls you need to run the script in. – choroba Aug 01 '19 at 17:20
  • (don't need `use IPC::System::Simple;` in order for `autodie` to work with `:all`, just that the module is on the system) – zdim Aug 01 '19 at 17:29
  • `cpanm` says that ` IPC::System::Simple` is already installed, but perlbrew cannot find it :( – con Aug 01 '19 at 17:29
  • @con, Re "*`cpanm` says that ` IPC::System::Simple` is already installed*", You are presumably using the wrong `cpanm`. You need to use the one installed by the `perl` for which you want to install modules. You probably didn't install one with the `perl` in question, and it's picking up another one in your path. Why complicate things by using `cpanm`? Just use `cpan IPC::System::Simple`. – ikegami Aug 01 '19 at 19:21
  • @ikegami unfortunately installing installing with `cpanm` still gives the same error :( even when I do the installation inside the perlbrew shell :( it's all up to date with version 1.25 – con Aug 01 '19 at 19:38
  • @con I've had similar trouble due to `local::lib` (and/or `PERL5LIB`) – zdim Aug 01 '19 at 20:09
  • 1
    Please provide the output of `which cpan; head -1 "$( which cpan )"; which perl; perl -le'print "$_=$ENV{$_}" for sort grep /^PERL/, keys %ENV;'` – ikegami Aug 01 '19 at 20:14
  • @ikegami in normal shell `/usr/bin/cpan #!/usr/bin/perl /usr/bin/perl` & perlbrew `/home/con/perl5/perlbrew/perls/perl-5.30.0/bin/cpan #!/home/con/perl5/perlbrew/perls/perl-5.30.0/bin/perl /home/con/perl5/perlbrew/perls/perl-5.30.0/bin/perl PERL5LIB= PERLBREW_LIB= PERLBREW_MANPATH=/home/con/perl5/perlbrew/perls/perl-5.30.0/man PERLBREW_PATH=/home/con/perl5/perlbrew/bin:/home/con/perl5/perlbrew/perls/perl-5.30.0/bin PERLBREW_PERL=perl-5.30.0 PERLBREW_ROOT=/home/con/perl5/perlbrew PERLBREW_SKIP_INIT=1 PERLBREW_VERSION=0.86 PERL_LOCAL_LIB_ROOT=` – con Aug 02 '19 at 13:55
  • 1
    One more: `/home/con/perl5/perlbrew/perls/perl-5.30.0/bin/perl -e'use IPC::System::Simple'; /home/con/perl5/perlbrew/perls/perl-5.30.0/bin/cpan IPC::System::Simple; /home/con/perl5/perlbrew/perls/perl-5.30.0/bin/perl -e'use IPC::System::Simple'` – ikegami Aug 02 '19 at 19:47
  • (I do have two things for you to change, but I'll wait for this answer first) – ikegami Aug 02 '19 at 19:48
0

The solution, according to @ikegami, and that worked for me: /home/con/perl5/perlbrew/perls/perl-5.30.0/bin/perl -e'use IPC::System::Simple'; /home/con/perl5/perlbrew/perls/perl-5.30.0/bin/cpan IPC::System::Simple; /home/con/perl5/perlbrew/perls/perl-5.30.0/bin/perl -e'use IPC::System::Simple'

of course, for anyone in the future, this will be slightly different for you, as your directories may be set differently, and username isn't con

con
  • 5,767
  • 8
  • 33
  • 62