problems with package resolution

406 views
Skip to first unread message

Stephen Dewey

unread,
Sep 12, 2017, 11:59:05 AM9/12/17
to Camelcade - Perl plugin for IntelliJ IDEA
Hi,

Thank you for creating this plugin. I am trying to use it for a project, but I am getting lots of problems with package resolution ("unable to find package file").

I am using the latest Strawberry Perl. I used CPAN to install Log::Log4perl, and I created a test script which uses it successfully. However, in Pycharm with Camelcade it cannot be found.

Similarly most of the libraries for my project cannot be found. 

I am confused by the difference between:
Settings->Project:lib->Project Structure->marking folders as Sources
and
Settings->Languages & Frameworks->Perl5->Project tab->adding External libraries
and
Settings->Languages & Frameworks->Perl5->lib tab->specifying folders as Perl5 libraries

Can you explain the difference?

Perhaps I have not setup my project libraries correctly, but I am a bit surprised that even Log4perl is not found.

Thanks in advance for your help!

Stephen

Stephen Dewey

unread,
Sep 12, 2017, 12:42:28 PM9/12/17
to Camelcade - Perl plugin for IntelliJ IDEA
I was solved one part of my problem. It seems that C:\Strawberry\perl\site\lib is not automatically included for some reason (only C:\Strawberry\perl\vendor\lib and C:\Strawberry\perl\lib). After I added C:\Strawberry\perl\site\lib to Settings->Languages&Frameworks->Perl5->Project->External libraries, it became found.

So now I only have problems with project files. I have an include statement like:
use Thing1::Util
so that I can use
Thing1/Util.pm

But it is not found. I have marked Thing1 as "Perl5 library" on the Perl5->lib dialogue, and I have also marked it as "Sources" on the Project Structure dialogue, but neither seems to work.

Alexandr Evstigneev

unread,
Sep 13, 2017, 2:30:00 AM9/13/17
to Camelcade - Perl plugin for IntelliJ IDEA
Currently Perl plugin uses it's own configuration, separated from IDEs. Python's source roots does not affecting Perl resolving in any way (at least they shouldn't).

Perl project model has it's own let's say @INC list, built from 3 sources combined:

  1. Interpreter's @INC, being fetched from perl itself, when you add a new interpreter. IDE just runs something like perl -le 'print for @INC', parsing and remembering results.
  2. External libraries, being configured in Settings->Languages & Frameworks->Perl->Project->External libraries. These are additional directories which are not inside your project (e.g. your other project with custom library)
  3. Project libraries. Specified on per-module basis with 'Mark as Perl5 library', e.g. your_project/lib.

So if you install Log4Perl with CPAN without specific tricks, it should go to some of the Perl's @INC dirs. 


When plugin attempts to search for pm file it's basically iterates all 3 lib paths sets and checks them.

Here is how it should look like:





вторник, 12 сентября 2017 г., 18:59:05 UTC+3 пользователь Stephen Dewey написал:

Stephen Dewey

unread,
Sep 13, 2017, 2:41:12 PM9/13/17
to Alexandr Evstigneev, came...@googlegroups.com
Sorry, I thought I was emailing the group. Adding it back on.

It's a shame about the subs resolutions since these are common cases. Maybe you could tell the plugin to simply ignore the cases where it is unsure, rather than assuming they are errors. Although maybe in that case the plugin would not be of much use, I am not sure.

On Wed, Sep 13, 2017 at 2:24 PM, Alexandr Evstigneev <hurr...@gmail.com> wrote:
Please, post questions in the group, to make it available for others.
Also, there is a #@type annotation for variables, as alternative to perl's syntax like my Foo::Bar $var (still not updated wiki, shame)
2. If you mark lib/ as lib root, means Foo::Bar should be in lib/Foo/Bar.pm
To make lib/a/Foo/Bar.pm work, a should be marked as lib too.

2017-09-13 20:51 GMT+03:00 Stephen Dewey <stephene...@gmail.com>:
Thanks, I think I understand the differences between the different library rules now. 

I figured out my first problem. I had not marked the top level of the project as a Perl5 library, only the ones below that. Once I marked the top level, some of the problems went away.

It seems there are still some problems with objects. If I have a method like this:
sub my_func {
  my $arg1 = pop
  
  my $var = $arg1->property
  $arg1->do_something()
}

Both property and do_something will be highlighted with the error "Unable to find sub definition, declaration..." Perhaps the problem is that Perl cannot know what the object type is (since Perl is dynamically typed) so there is no way to know what will be passed. Is this error therefore inevitable, or is there something to be done?

Similarly if you do:

my $log = Log::Log4perl->get_logger(__PACKAGE__);
$log->info("Hello.");

The info() will have the same error.

An unrelated question: Is marking a folder as "Perl5 library" recursive? i.e. if I have
MyFolder
MyFolder/a
MyFolder/b
Do I have to mark a and b as "Perl5 library" or is it sufficient to mark MyFolder?

Thank you again,
Stephen

--
You received this message because you are subscribed to the Google Groups "Camelcade - Perl plugin for IntelliJ IDEA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camelcade+unsubscribe@googlegroups.com.
To post to this group, send email to came...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/camelcade/5cabe093-c3c9-40e7-96bd-d44c4305f521%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



Owen S.

unread,
Jul 30, 2019, 1:05:13 PM7/30/19
to Camelcade - Perl plugin for IntelliJ IDEA
Hi Alexandr,

I'm also having a problem with package resolution, also seeing the message "Unable to find sub definition, declaration, constant definition or typeglob aliasing"

So I'm hijacking this old thread, but I think in my case the cause is a little different -- it seems that the plugin is prioritizing the system-level perl library over the "internal" libraries I marked in the plugin configuration.  In my case, there are modules with the same name in the system and internal library -- but I need methods that are only available in the internal library.

Is there a way to specify priority of multiple perl5 libraries?

Thanks,
Owen
To unsubscribe from this group and stop receiving emails from it, send an email to came...@googlegroups.com.

To post to this group, send email to came...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages