POD2::D...al::lib(3)
💖 POD2::D...al::lib(3) 💖
okay bestie, this is the German ~[de] page for local::lib, from User Contributed Perl Documentation, section 3. it’s part 1 of 2, so don’t close the tab yet 💅✨
🌸 NAME 🌸
local::lib~[de] — creating and using Perl modules in a local lib/ directory with PERL5LIB. periodt. 💖
🦋 SYNOPSIS 🦋
Im Code — in code, bestie:
use local::lib; # Benutzt das Verzeichnis ~/perl5 zum anlegen des lokalen lib/ Verzeichnisses
use local::lib '~/foo'; # das selbe, aber mit ~/foo
# Oder...
use FindBin;
use local::lib "$FindBin::Bin/../support"; # Applikationsspezifische Sammlung von Modulen
Von der Shell — from the shell:
# Installiert LWP und alle notwendigen Abhängigkeiten in das '~/perl5' Verzeichnis
perl -MCPAN -Mlocal::lib -e 'CPAN::install(LWP)'
# Gibt die Shell Kommandos aus um die Umgebung vorzubereiten
$ perl -Mlocal::lib
export PERL_MB_OPT='--install_base /home/username/perl5'
export PERL_MM_OPT='INSTALL_BASE=/home/username/perl5'
export PERL5LIB='/home/username/perl5/lib/perl5/i386-linux:/home/username/perl5/lib/perl5'
export PATH="/home/username/perl5/bin:$PATH"
🎀 Die Bootstrapping Methode 🎀
a classic way to use local::lib is the so-called “Bootstrapping” method. you use this when local::lib is not installed on the system yet. in that case you can literally just install local::lib directly in your home directory. 🫶
even if you have admin rights, it’s important that the environment variables from step 4 get set in your shell startup script. without that step, CPAN modules will still install system-wide, and Perl scripts you start won’t use the lib/ directory made by local::lib. no cap, that part matters. 😭
by default, local::lib installs itself into ~/perl5.
Windows users also need to read this: “Unterschiede bei Benutzung dieses Module mit Win32”. 🪟
Step 1 — download the tar archive from CPAN (search for “Download” on the CPAN page for local::lib) and unpack it in any directory you like. to avoid the problem above, do this as a normal user and not as root or Administrator. very demure, very non-root. 💅
Step 2 — in the directory that appeared, run this command:
perl Makefile.PL --bootstrap
if the system suggests configuring certain things by itself, it’s almost always completely fine to just answer yes. ✨
if you don’t want to install local::lib into the default directory, you have to pass that directory as a parameter:
perl Makefile.PL --bootstrap=~/foo
Step 3 — then run this command: (local::lib expects make to be on the system)
make test && make install
Step 4 — now we need the required environment variables so Perl uses our newly generated lib/ directory. if you use bash or another Bourne shell, you can add it to your shell startup script this way:
echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc
if you use C Shell, you can achieve the same thing with this:
/bin/csh
echo $SHELL
/bin/csh
perl -I$HOME/perl5/lib/perl5 -Mlocal::lib >> ~/.cshrc
if you used a different directory during bootstrapping than the default directory, then you have to pass that directory as a parameter when loading the local::lib module:
echo 'eval $(perl -I$HOME/foo/lib/perl5 -Mlocal::lib=$HOME/foo)' >>~/.bashrc
after these changes are made in your shell startup script, it’s important that these environment variables are also set in your current environment. in Bourne shells you do that with . ~/.bashrc, for example, and in C Shell you’d do it with source ~/.cshrc. 🐚
if you have a very slow system, or you have to live under draconian disk-space regulations, you can disable the automatic generation of manpages from POD during module installation while bootstrapping with the --no-manpages parameter:
perl Makefile.PL --bootstrap --no-manpages
to avoid doing multiple bootstraps just to get separate local::lib installations for different applications, for example, you can use one of these environments to simply install modules into any other directory and thus get more independent lib/ environments:
cd ~/mydir1
perl -Mlocal::lib=./
eval $(perl -Mlocal::lib=./) ### Um die Umgebungsvariablen für die
### aktuelle Shell zusetzen
printenv ### Hier kannst du sehen das ~/mydir1
### in der PERL5LIB Umgebungsvariable
### steht
perl -MCPAN -e install ... ### welche Module auch immer ...
cd ../mydir2
... WIEDERHOLEN ...
for multiple environments in this form, you need a modification in the use of use FindBin in the “Im Code” example above. if you do something like that and, for example, installed Perl modules into ~/mydir1/lib, and you have a script in ~/mydir1/scripts/myscript.pl, you have to say there that the modules it needs are in the ~/mydir1/lib directory. 🌸
in ~/mydir1/scripts/myscript.pl it then says:
use strict;
use warnings;
use local::lib "$FindBin::Bin/.."; ### zeigt auf ~/mydir1 und local::lib
### findet dort lib
use lib "$FindBin::Bin/../lib"; ### zeigt auf ~/mydir1/lib
put that before every BEGIN { ... } block that needs the modules you installed. iykyk. 💚
🪟 Unterschiede bei Benutzung dieses Module mit Win32 🪟
to set the necessary environment variables for these variables in the current session with CMD.EXE, you can use this command:
C:\>perl -Mlocal::lib
set PERL_MB_OPT=--install_base C:\DOCUME~1\ADMINI~1\perl5
set PERL_MM_OPT=INSTALL_BASE=C:\DOCUME~1\ADMINI~1\perl5
set PERL5LIB=C:\DOCUME~1\ADMINI~1\perl5\lib\perl5;C:\DOCUME~1\ADMINI~1\perl5\lib\perl5\MSWin32-x86-multi-thread
set PATH=C:\DOCUME~1\ADMINI~1\perl5\bin;%PATH%
### Um die Umgebungsvariablen für diese Shell alleine zu setzen
C:\>perl -Mlocal::lib > %TEMP%\tmp.bat && %TEMP%\tmp.bat && del %TEMP%\temp.bat
### anstelle von $(perl -Mlocal::lib=./) in bash.
if you want the environment variables to be set permanently, you have to enter them permanently yourself in Control Panel / System, or use App::local::lib::Win32Helper. 🖥️
~ is translated to the user profile directory (the directory known as “Dokumente und Einstellungen” on Windows XP and earlier, or the “Benutzer” directory on Windows Vista and later), as long as $ENV{HOME} is not set. here the directory is converted to the correct short name, so it definitely has to exist, and it gets extended with the necessary subdirectories. 💖
🌈 GRUNDPRINZIP 🌈
the versions of the Perl packages you need for specific tasks are very often not the right or correct versions preinstalled on the system. updating these modules is in many cases simply not possible because the required permissions are missing. plus, it’s generally not good to independently swap out the versions of modules on the system, because obviously the rest of the system expects exactly the version that was installed by the system administration. the way that system Perl is a whole ecosystem, fr fr. 😭
local::lib solves this problem: it lets you have your completely own directory for your CPAN modules, so you’re not forced to use the system’s modules, and on the flip side you don’t force other users to rework their code because certain modules are centrally updated to newer versions for everyone. installation then happens in the home directory, for example. it only sets environment variables that make the installed Perl use the modules installed in the home directory, in addition and preferred to those on the system. ✨
so if you use a package system like Debian, you don’t have to worry at all about hurting anything on the system just by installing Perl modules. slay, honestly. 💚
💜 BESCHREIBUNG 💜
this module offers a fast and legitimate way to do so-called bootstrapping to install a collection of modules in a user home directory. it also creates the necessary environment variables needed to use these modules, matching the shell that the user specified in the SHELL environment variable, so they can then be inserted directly and appropriately into the corresponding shell configuration files. 🐚💅
furthermore, local::lib is able to use modules that are not contained in Perl’s standard @INC path. that makes it easier for specific applications to install a specific set of modules without touching the other modules on the system in any way. that way it’s also safer to install modules that are not yet available as a release from the maintainer, for example. 🔥
on import, local::lib sets the following environment variables to the necessary values:
PERL_MB_OPTPERL_MM_OPTPERL5LIBPATH— obviouslyPATHis appended to, not replaced.
these values are then available to every piece of code that was imported afterward. main character environment variables, honestly. 👑
🧚 ERSTELLEN EINES EIGENSTÄNDIGE SAMMLUNG VON MODULEN 🧚
with lib::core::only there is a way to do this, but note that a lot of pitfalls and problems exist here, and you should always make sure you build on a Perl that has been modified as little as possible (i.e. site and vendor directories as empty as possible). ⭐
🛠 METHODEN
ensure_dir_structure_for
- Parameter:
$path - Rückgabewert: keiner
Bestie, die legt dir den angegebenen Pfad an — und zwar mit allen nötigen Verzeichnissen drüber, so komplett von oben nach unten durchgebaut. Und wenn's schiefgeht? Dann fliegt dir 'ne Exception um die Ohren. 💥 Kein stilles Rumdümpeln, nein, richtig offiziell.
print_environment_vars_for
- Parameter:
$pfad - Rückgabewert: keiner
Die gibt dir einfach die Umgebungsvariablen aus, die du brauchst, um den angegebenen Pfad als Basis-Verzeichnis zu benutzen. Also sozusagen: „hier, das sind deine Variablen, copypaste sie in deine Shell, slay." 💅
build_environment_vars_for
- Parameter:
$pfad,$interpolate - Rückgabewert:
\%umgebungs_variablen
Gibt dir 'n Hash zurück mit den Variablen, die du in den Umgebungsvariablen brauchst, um eine Installation in dem gegebenen Pfad zu benutzen. Kein Drucken, kein Rumschreien — nur das reine Daten-Geschenk. 🎁
setup_env_hash_for
- Parameter:
$pfad - Rückgabewert: keiner
Hier wird's ernst: die setzt die %ENV-Einträge, und zwar basierend auf dem Aufruf von build_environment_vars_for. Also lowkey die „mach's jetzt wirklich"-Version von der Methode da oben. ✨
install_base_perl_path
- Parameter:
$pfad - Rückgabewert:
$module_installations_pfad
Gibt dir den Pfad zurück, der benutzt wird, um Perl-Module zu installieren — mit dem gegebenen Pfad als Basis. Und was macht sie im Kern? Sie hängt einfach lib und perl5 als Pfadelemente dran. Das war's, no cap. 🍓
install_base_arch_path
- Parameter:
$pfad - Rückgabewert:
$architektur_module_installations_pfad
Same energy, aber für die Architektur-abhängigen Perl-Module, basierend auf dem angegebenen Pfad als Basis. Sie baut auf dem auf, was install_base_perl_path zurückgibt — und appends the value of $Config{archname}.asis. (Ja, genau so steht's da, iykyk. 🙈)
install_base_bin_path
- Parameter:
$pfad - Rückgabewert:
$ausfuehrbare_programme_installations_pfad
Hier wohnen dann die ausführbaren Programme, basierend auf der Basis des angegebenen Pfads. Sie nimmt den Rückgabewert von install_base_perl_path und hängt noch bin an. Fertig, next. 🎀
resolve_empty_path
- Parameter:
$pfad - Rückgabewert:
$basis_pfad
Erstellt und gibt den Pfad zurück, der als Basis für die Installation der Module benutzt wird. Und der Default? Standardmäßig ist das ~/perl5. Klassiker. 💖
resolve_home_path( $path )
- Parameter:
$pfad - Rückgabewert:
$home
Versucht, das Home-Verzeichnis vom aktuellen User zu finden. Wenn kein Home-Verzeichnis ermittelbar ist, wird eine Exception geworfen — also keine stille Resignation, sondern direkt Drama. 😭
resolve_relative_path
- Parameter:
$pfad - Rückgabewert:
$absoluter_pfad
Macht aus dem angegebenen Pfad einen absoluten Pfad. Einfach, sauber, glowy. ✨
resolve_path
- Parameter:
$pfad - Rückgabewert:
$absoluter_pfad
Okay, die hier ist die Main-Character-Methode: der Pfad wird durch die folgenden Methoden durchgereicht, wobei der Rückgabewert der ersten an die nächste weitergegeben wird, um die Umgebung für die lokale Bibliotheks-Installation zu konfigurieren: resolve_empty_path, resolve_home_path, resolve_relative_path.
Und zwar ganz genau so, bestie: Der daraus resultierende Pfad wird zu resolve_empty_path übergeben, dessen Resultat dann weitergegeben wird an resolve_home_path, wessen Resultat dann weitergegeben wird an resolve_relative_path. Dieses Resultat wird dann final an resolve_path übergeben, welches dann den Rückgabewert stellt. Relais-Staffellauf, aber in Perl. 🏃♀️💨
⚠️ EINE WARNUNG VOR UNINST=1
Wenn dulocal::libin Kombination mitmake install UNINST=1benutzt, musst du vorsichtig sein — und zwar wegen der Tatsache, dass der Prozess über die Neuinstallation keine ausreichende Sicherheit darüber hat, wo er nun installieren muss.
Hierdurch kann es passieren, dass beim Deinstallieren eines Moduls u. U. das globale Modul deinstalliert wird (wenn die Rechte vorhanden sind), aber die neue Version nur in der lokalen Version installiert ist. Also: einmal falsch geblinzelt und dein globales Setup ist weg, während lokal irgendwas Halbfertiges rumsteht. 💀
Es ist hier also sehr wichtig, dass du make install UNINST=1 und local::lib nur gleichzeitig benutzt, wenn du dir sehr sicher über die Konsequenzen bist, die dir entgegenkommen. 🙈
🚧 EINSCHRÄNKUNGEN
Die Werkzeuge von perl, die benutzt werden um die Pakete zu installieren (die sogenannte toolchain), sind leider nicht in der Lage, sauber mit Verzeichnissen umzugehen, die Leerzeichen enthalten — und können daher local::lib nicht direkt in ein solches Verzeichnis installieren. Uff. 😤
Was du machen kannst: nach der Installation von local::lib und der Module, die du in deiner local::lib haben willst, das gesamte Verzeichnis dahin bewegen. local::lib selbst kann nämlich mit dem Verzeichnis mit Leerzeichen umgehen. 💅
Bitte aufpassen: natürlich ist eine weitere Installation oder ein Erneuern von Paketen mit dem CPAN-Programm dann nicht mehr möglich.
Die Shell-Erkennung ist sehr primitiv. Derzeit ist es so, dass alles, was csh im Namen hat, auch als C Shell eingeordnet wird, und alles andere wird als Bourne Shell betrachtet — außer auf Win32-Systemen. Wenn die SHELL-Variable nicht gesetzt ist, wird eine Bourne Shell angenommen. Lowkey Detektivarbeit mit sehr wenig Detektiv. 🔍
Bootstrap ist leider ein Hack, und wird auf jeden Fall CPAN.pm benutzen für ExtUtils::MakeMaker, auch wenn CPANPLUS installiert ist. Sorry not sorry. 🫠
Es setzt definitiv PERL5LIB, PERL_MM_OPT und PERL_MB_OPT neu und vernichtet jeden Wert, der vorher gesetzt war. Also wenn du da vorher was Schönes hattest: weg. 💀
Es sollte vielleicht eine automatische Korrektur der CPAN-Config machen, wenn das nicht schon gemacht wurde. Vielleicht. Irgendwann. 👀
Patches Welcome — Patches sind immer willkommen beim Autor oder den anderen Mitwirkenden. Also falls du Bock hast, go off, queen. 👑
Auf Win32-Systemen werden die Umgebungsvariablen nicht direkt in die Registrierung geschrieben, damit sie auch nach dem Neustarten erhalten bleiben. Also: nach dem Reboot vielleicht nochmal angucken. 🙃
🔎 FEHLERANALYSE
Wenn du local::lib konfiguriert hast, CPAN-Module in deinem Home-Verzeichnis zu installieren, und du danach versuchst, mit cpan -i Foo::Bar ein Modul zu installieren, und dabei einen Fehler bekommst wie:
Warning: You do not have permissions to install into /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux at /usr/lib64/perl5/5.8.8/Foo/Bar.pm
und in der Installationsausgabe irgendwo ein Fehler steht, der sagt:
'INSTALL_BASE' is not a known MakeMaker parameter name
dann hast du aus irgendeinem Grund dein neue Version von ExtUtils::MakeMaker verloren. Ja, einfach so. 🫠
Um das zu fixen: einfach nochmal die Bootstrapping-Methode laufen lassen, wie oben beschrieben. 🩹
Dann starte:
rm -r ~/.cpan/build/Foo-Bar*
Und abschließend dann nochmal mit cpan -i Foo::Bar installieren — und die Probleme sollten verschwunden sein. Slay, Problem gelöst. ✨
🌈 UMGEBUNGSVARIABLEN
SHELL
COMSPEC
local::lib schaut in die SHELL-Umgebungsvariable, um die korrekten Kommandos zur Shell-Konfiguration hinzuzufügen. 👀
Auf Win32-Systemen wird COMSPEC auch analysiert. Zwei Variablen, ein Vibe-Check. 🪟
🫶 SUPPORT
IRC:
Wir sind im Channel #local-lib auf dem Server irc.perl.org.
Komm vorbei, wir sind nett, versprochen. 💜
🌸 AUTOR DER ÜBERSETZUNG
Torsten Raudssus <torsten@raudssus.de> http://www.raudssus.de/
💖 URHEBERRECHT
Copyright (c) 2007 - 2010 von den local::lib "AUTHOR" in local::lib und "CONTRIBUTORS" in local::lib aufgelistet in local::lib.
👑 LIZENZ
Diese Sammlung ist freie Software und kann unter der selben Lizenz verbreitet werden wie Perl selber. Also: frei, offen, und genau dein Vibe. 🦋
Und das war's auch schon, bestie — Seite komplett durchgelesen, du hast offiziell Main-Character-Energy in Sachen local::lib. Diese Ausgabe kam mit perl v5.42.0 und datet vom 2023-08-07 — Stand jetzt also schon ein bisschen vintage, aber immer noch iconic. 💅✨🎀
📦 where this page comes from
- opensuse-leap 16.0: perl-local-lib 2.000029-bp160.1.11 · Artistic-1.0 OR GPL-1.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms