nickandrew / LS30

Control software for LS-30 alarm system
11 stars 3 forks source link

@NIC include path #3

Closed gdruce closed 13 years ago

gdruce commented 13 years ago

Could be a local config issue but straight out of the download I found the code had problems finding the library files. eg errors like

Can't locate AlarmDaemon/Controller.pm in @INC (@INC contains: .....

Easiest way for me to work around it, was to add the local lib path via the following line at the top of each file.

#add a local path to lib
use lib './lib'; 
nickandrew commented 13 years ago

The correct response is to execute this command before running any daemon or script:

export PERLLIB=./lib

That takes care of finding modules when your current directory is the top directory of the repository. If you do instead:

export PERLLIB=$PWD/lib

then you can move around the filesystem afterward and the code will still work.

The reason to use $PERLLIB instead of 'use lib' is the code shouldn't contain any assumptions about which directory it is installed in. If the LS30 code is packaged then the modules would be installed under /usr/share/perl5 which is a standard location for perl to find modules and neither $PERLLIB nor 'use lib' would be required.