NAME
find_ld_dirs - prepend blib/arch/auto dirs to LD_LIBRARY_PATH
SYNOPSIS
find_ld_dirs
# To walk from the logical bin ($Bin_l) instead of the physical
# ($Bin_p), add "noabspath" to the FindBin::libs import:
#
# use FindBin::libs qw( ld_lib base=blib subdir=arch/auto subonly noabspath );
DESCRIPTION
Walks up from the script's bin directory collecting blib/arch/auto subdirectories and prepending them to LD_LIBRARY_PATH. Useful when running XS modules whose .so files live under a local blib tree built with make.
The walk uses subonly: only blib/arch/auto dirs are added, not bare blib dirs.
abspath vs. noabspath
FindBin::libs starts its directory walk from one of two paths exported by FindBin::Bin:
- abspath (default)
-
Walks from
$Bin_p, the physical path resolved byCwd::abs_path. All directory symlinks are resolved before the walk begins (likepwd -P).# /home/user/app -> /work/projects/app (directory symlink) # invoked as: /home/user/app/bin/myscript abspath walk: /work/projects/app/bin -> /work/projects/app -> ... finds: /work/projects/app/blib/arch/autoThis is the default: the
blibtree is always found next to where the source file actually lives on disk, regardless of how the script was invoked. - noabspath
-
Walks from
$Bin_l, the logical path computed bycanon_dir. Directory symlinks are left in place (likepwd -L).# Same layout as above. noabspath walk: /home/user/app/bin -> /home/user/app -> /home/user -> ... finds: /home/user/blib/arch/auto (if it exists)Use
noabspathwhen the script is invoked through a directory symlink that sits inside a sandbox with its ownblibtree:/sandbox/ +-- blib/arch/auto/MyMod/MyMod.so # test .so built here \-- app -> /work/projects/app # symlink to real bin/ noabspath walk: /sandbox/app/bin -> /sandbox/app -> /sandbox finds: /sandbox/blib/arch/auto # picks up the test .so
FindBin::Bin: $Bin_l and $Bin_p
FindBin::Bin exports three variables for the directory containing the running script:
$Bin_l-
Logical path (
canon_dir, likepwd -L). Removes..and.segments without touching the filesystem; symlinks are preserved. $Bin_p-
Physical path (
Cwd::abs_path, likepwd -P). Resolves all directory symlinks to their real on-disk location. $Bin-
An alias. Equals
$Bin_pby default (physical, abspath); equals$Bin_lwhen the caller passesnoabspathtoFindBin::Bin. This matchesFindBin::libsbehavior:use FindBin::Bin qw( $Bin ); # $Bin == $Bin_p (physical, default) use FindBin::Bin qw( $Bin noabspath ); # $Bin == $Bin_l (logical) use FindBin::Bin qw( $Bin abspath ); # $Bin == $Bin_p (physical, explicit)