skip to Main Content

I’m developing a large perl module which works like a charm when running from Terminal. When running i with Intellij IDEA CE, the following error pops up. This happens in all major versions of the software.

My programm starts:

#!/usr/bin/env perl

use strict;
use warnings;
use utf8;
use feature qw (say);

use Getopt::Long;

use lib 'lib';
die('this is a test');
...

Perls own lib.pm starts like this

package lib;

# THIS FILE IS AUTOMATICALLY GENERATED FROM lib_pm.PL.
# ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN BY THE NEXT PERL BUILD.

use Config;

use strict;

my $archname         = $Config{archname};
my $version          = $Config{version};
my @inc_version_list = reverse split / /, $Config{inc_version_list};

our @ORIG_INC = @INC;   # take a handy copy of 'original' value
our $VERSION = '0.65';
...

In Intellij IDEA this leads to

/usr/bin/perl -I/home/user/git/mytool/lib -I/home/user/git/mytool/lib/Download /home/user/git/mytool/download.pl Digi20
Global symbol "%Config" requires explicit package name (did you forget to declare "my %Config"?) at /usr/lib/x86_64-linux-gnu/perl-base/lib.pm line 10.
Global symbol "%Config" requires explicit package name (did you forget to declare "my %Config"?) at /usr/lib/x86_64-linux-gnu/perl-base/lib.pm line 11.
Global symbol "%Config" requires explicit package name (did you forget to declare "my %Config"?) at /usr/lib/x86_64-linux-gnu/perl-base/lib.pm line 12.
Compilation failed in require at /home/user/git/mytool/download.pl line 10.

I don’t know where these -I params to the perl executable are configured. In the run dialog, i configured no params for perl.

Ubuntu 22.04 LTA + Perl 5.34. On my home office machine everything works fine, too. But on the office machine not. Syncing IDE settings home > office does not help.

Found another user having a similar issue on Eclipse but the error comes from another module. My Config module is already named Download::Config.

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution:

    Intellij IDEA adds the configured library destinations as -I param to the perl call. Mind the purple marker here in the picture. The Download folder was purple, too. That caused the error.

    Intellij Perl library settings dialog

    There is a similar setting in the project structure settings but this does not cause -I parameters being added.


  2. There’s a module call Config that comes with Perl. It exports a hash named %Config by default.

    The error is due to %Config not being exported by by use Config;.

    I’m guessing a different module named Config is being picked up by use Config;. You can verify this using BEGIN { print "$INC{'Config.pm'}n" } after the use Config;.

    You should name your module something else.


    That said, I suspect you don’t actually have a module named Config. I suspect you have a module named Download::Config (which is perfectly fine), but /home/user/git/mytool/lib/Download is being incorrectly added to @INC.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search