CPANを一般ユーザ権限で使う
一般ユーザの権限しか与えられてない環境で CPAN モジュールを 使うための方法メモ.
まずはモジュールのインストール先をユーザーホーム以下に設定する.
CPAN モジュールの対話的設定時に以下のような画面になると思うので,
ヒント通りに PREFIX=~/perl
などと打つ.
この設定により,以降 CPAN でインストールされるモジュールは
"~/perl" 以下に配置されることになる.
Parameters for the 'perl Makefile.PL' command? Typical frequently used settings: PREFIX=~/perl non-root users (please see manual for more hints) Your choice: []
すでにインストールが終わっている場合,
設定ファイル "~/.cpan/CPAN/MyConfig.pm"
の
'makepl_arg'
に対応する値を変更すれば良い.
次に,Perl インタプリタがユーザホーム以下の "~/perl" ディレクトリを
モジュール検索ディレクトリとして認識するように設定する.
これには PERL5LIB
環境変数を利用する.
PERL5LIB
環境変数については,"man perlrun"
に以下のような説明がある.
# man perlrun
...
PERL5LIB A list of directories in which to look for
Perl library files before looking in the stan-
dard library and the current directory. Any
architecture-specific directories under the
specified locations are automatically included
if they exist. If PERL5LIB is not defined,
PERLLIB is used. Directories are separated
(like in PATH) by a colon on unixish platforms
and by a semicolon on Windows (the proper path
separator being given by the command "perl
-V:path_sep").
というわけで,自分は現在 ".bash_profile"
に以下の行を書き込んでいる.
export PERL5LIB=$HOME/perl/lib/perl5/site_perl/5.8.8/:$HOME/perl/lib/perl5/site_perl/5.8.8/mach/
ちょっと汚い記述だが,ちゃんと動く.