I'm using emacs 26.3 under FreeBSD 12 environment and try to use PDE. My problem is that in the runtime environment the modules (@INC array) are properly addressed by the PERL5LIB variable. But using emacs and PDE or flycheck, flymake the local PERL5LIB is ignored. What do I've to do to get the emacs setup running?


For my own perl5modules, I've a special place in my home directory ~/lib/perl5, which is addressed by the enviromnent variable

export PERL5LIB=$HOME/lib/perl5

by my bash shell resource script .bashrc. Modules from project directories are soft linked from the project directory into the perl5 library location. For an example I've a project in $HOME/project/daisi-lts with a perl5 module repository in it, under


. It is soft linked by

$ ln -s $HOME/project/daisi-lts/lib/perl5/Daisi $HOMElib/perl5/Daisi
$ ls lib/perl5/Daisi/
Common.pm   Parser Progress.pm

$ head lib/perl5/Daisi/Common.pm 
# =====================================================================
# Package Common.pm  utils, dictioaries and constants for the
# daisi backup suite
# =====================================================================
package Daisi::Common;
use v5.20.1;
use strict;

So the file is present. To test the strange behavoir I've written the following program:

#!/usr/bin/env perl
use strict;
    print " --- MODULE PATH --- \n";
    for my $path (@INC) {
        my $status = -e $path ? 'OK' : 'MISSING';
        print "PATH: $path $status\n";
    print " ------- EOF ------- \n\n";

    print " --- TEST VERSION --- \n";
    use Daisi::Common;
    my $APP_DICT = Daisi::Common::createAppDict(
        'VERSION 1.0','2020-01-23', 'user@host',  'user');
    Daisi::Common::version($APP_DICT, $0, 1 );
    print " ------- EOF ------- \n\n";

If try to use the PDE for syntax check I get the error!

Can't locate Daisi/Common.pm in
@INC (you may need to install the Daisi::Common module) \
(@INC contains: /usr/local/lib/perl5/site_perl/mach/5.30 \
               /usr/local/lib/perl5/site_perl \
               /usr/local/lib/perl5/5.30/mach \
               /usr/local/lib/perl5/5.30) at test-inc line 14.\
 BEGIN failed--compilation aborted at test-inc line 14.

If I using the shell environment everything is fine:

$/usr/bin/env perl test-inc 
--- MODULE PATH --- 
PATH: /home/i4w/lib/perl5 OK
PATH: /usr/local/lib/perl5/site_perl/mach/5.30 OK
PATH: /usr/local/lib/perl5/site_perl OK
PATH: /usr/local/lib/perl5/5.30/mach OK
PATH: /usr/local/lib/perl5/5.30 OK
 ------- EOF ------- 

 --- TEST VERSION --- 
test-inc VERSION: VERSION 1.0 DATE: 2020-01-23 CONTACT: <user> user@host

What info do I've to give emacs to get it work?

For the PDE the setup I use following elisp settings:

(add-to-list 'load-path "~/lib/emacs/pde")
(load "pde-load")

(require 'flycheck)
(global-flycheck-mode t)

EDIT and some tests after the advice of Stephan:

It is a little bits scatter over the config variables.

  1. The vaue of the perl environment (query in elisp) is empty.

    (getenv "PERL5LIB") is nil

  2. Setting the shell environment according to Keith Flower "I think both M-x shell-command and M-x compile execute commands in an inferior shell via call-process." via elisp

    (setq shell-file-name (getenv "SHELL"))

    (setq shell-command-switch "-ic")

will correct the wrong behavior of PDE Check syntax (C-c s) but not for flycheck.

  1. Duplicate explicitly the setup of PERL5LIB via elisp:

    (setenv "PERL5LIB" (concat (getenv "HOME") "/lib/perl5"))

    will work for the PDE and for flymake, flycheck too.

But why does emacs bypasses/ ignores the user shell settings?

  • My crystal ball says you're not starting Emacs from your bash shell but from your graphical environment: see exec-path-from-shell – Stefan Feb 1 '20 at 13:48
  • Hm, that is interesting because M-! echo $SHELL gives me /usr/local/bin/bash., and C-x C-e (getenv "SHELL") too. How does the graphical process startup of emacs by pass the the default user shell settings? – huckfinn Feb 1 '20 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.