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 by Cwd::abs_path. All directory symlinks are resolved before the walk begins (like pwd -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/auto

This is the default: the blib tree 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 by canon_dir. Directory symlinks are left in place (like pwd -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 noabspath when the script is invoked through a directory symlink that sits inside a sandbox with its own blib tree:

/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, like pwd -L). Removes .. and . segments without touching the filesystem; symlinks are preserved.

$Bin_p

Physical path (Cwd::abs_path, like pwd -P). Resolves all directory symlinks to their real on-disk location.

$Bin

An alias. Equals $Bin_p by default (physical, abspath); equals $Bin_l when the caller passes noabspath to FindBin::Bin. This matches FindBin::libs behavior:

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)

SEE ALSO

FindBin::Bin, FindBin::libs, FindBin::Parents