#622 A not set ENV causes red error icon.

closed-invalid
nobody
None
5
2011-02-24
2011-02-24
Anonymous
No

Eclipse 3.6.1
EPIC 0.6.39
Kubuntu 10.04

I started eclipse per bash and got a red error icon in the line "use test qw/test_sub/;" Errormessage: Compilaton failed in require.
The bash says:
-----------------------------------------
OUTPUT
-----------------------------------------
env missing
Compilation failed in require at - line 6.
BEGIN failed--compilation aborted at - line 6.

-----------------------------------------

If I export the environment variable TEST and start eclipse again, everything is fine.

Here are the 2 test files:

file a.pl:
#!/usr/bin/perl

use strict;
use warnings;

use test qw/test_sub/;

print "hello\n";
test_sub();

----------

file test.pm
package test;

require Exporter;
@ISA=qw(Exporter);
@EXPORT_OK = qw/test_sub/;

use strict;
use warnings;

my $env = $ENV{TEST};
unless ( defined($env) ) {
die "env missing\n";
}

sub test_sub {
print "test sub called\n";
}

1;

I got a similar problem, for a line like this in the .pm file:
qx(/tmp/file/ .....);

STDOUT says:
-----------------------------------------
OUTPUT
-----------------------------------------
Can't exec "/tmp/file": Datei oder Verzeichnis nicht gefunden at test.pm line 16.
ERROR! Unable to determine file! at - line 21
Compilation failed in require at - line 21.
BEGIN failed--compilation aborted at - line 21.

Discussion

  • Jan Ploski
    Jan Ploski
    2011-02-24

    • status: open --> closed-invalid
     
  • Jan Ploski
    Jan Ploski
    2011-02-24

    You will get the same errors if you attempt to compile your code on the command line with perl -c a.pl. Not an EPIC bug.

     
  • lars meier
    lars meier
    2011-02-24

    Ok, thanks. 2 questions:

    - Do I have another option than export the environment vars before starting eclipse? I deactivated the validation every n seconds in the Epic menue, but that did not help. An I tried to set tne ENV in the run configurations, but that did not help, too.

    - Where can I read about this behaviour and EPIC? I serched much withoud having any idea or hint. The tooltip of the red icon says nothing really helpfull.

     
  • Jan Ploski
    Jan Ploski
    2011-02-24

    In order to check the syntax, EPIC invokes perl -c on each file, which indeed inherits the environment from Eclipse. The compilation stage in Perl does actually execute code (from BEGIN blocks, but also variable initializers in modules, as in your case). The errors you see are emitted by your own code being executed, hence not related to EPIC.

    Making sure the environment of Eclipse is set up as necessary is one option. Another one is to modify your code so that it doesn't execute and attempt to access the environment until you actually run the script (which is a good practice, generally speaking; the whole concept of automatically running code while it is being compiled appears crazy, but hey, we're talking about Perl).

     
  • lars meier
    lars meier
    2011-02-24

    Ok, thanks.

    Is it possible to add documentation to sub x in a.pm. Than use the sub in another .pl and get it's documentation here as tooltip or something?

     
  • Jan Ploski
    Jan Ploski
    2011-02-24

    No, it's not possible (not currently implemented in any form and also impossible to implement well for Perl in general).

     
  • lars meier
    lars meier
    2011-02-24

    That's a pity, but thanks again. So I need not to search anymore. Nevertheless I think I will change from Emacs to EPIC. The last think I'am looking for is autocompletion for subs. INDIV->test_sub(); does work very well, but it is not recommended to call a sub as method. Calling it INDIV::test_sub() is not recommended, too. Does EPIC support autocompletion for subs? So that I can write te, press STRG+Space and it works? Maybe after a little configuration? (-:

     
  • Jan Ploski
    Jan Ploski
    2011-02-24

    EPIC doesn't attempt to find out which symbols are or aren't imported when you use a module (which would require running parts of your code). So the autocompletion only works after :: or -> (the latter rather badly for variables, using a regex to find a constructor call and infer the type of the referenced object).