cygwinでcpanを使ってエラー
はじめに
cygwin環境下でcpanを使った際,エラーが発生しインストールができない場合がある.以下のような状況である./cygdrive/c/program: not found
が発生してインストールができない.
cpan> install Pod::Man Running install for module Pod::Man Running make for R/RR/RRA/podlators-1.27.tar.gz LWP not available Fetching with Net::FTP: ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/authors/id/R/RR/RRA/podlators-1.27.tar.gz CPAN: Digest::MD5 loaded ok LWP not available Fetching with Net::FTP: ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/authors/id/R/RR/RRA/CHECKSUMS Checksum for /cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/sources/authors/id/R/RR/RRA/podlators-1.27.tar.gz ok Scanning cache /cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/build for sizes /cygdrive/c/program: not found ←エラー /cygdrive/c/program: not found ←エラー Uncompressed /cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/sources/authors/id/ R/RR/RRA/podlators-1.27.tar.gz successfully Using Tar:/cygdrive/c/program files/cygwin/bin/tar xvf /cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/sources/authors/id/R/RR/RRA/podlators-1.27.tar: /cygdrive/c/program: not found ←エラー Couldn't untar /cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/sources/authors/id/R/RR/RRA/podlators-1.27.tar
メッセージの通り,空白を含むディレクトリが途中で切れてしまい,必要なコマンドを見つけることができないためだ.以下の手順で解消できる.
cpanの設定ファイルを確認
cpanを最初に動かした際に色々指定した内容は設定ファイルに書き込まれている.そのファイルを探す.まずcpanをシェルモードで動かし,o confと打ち込む.
$ perl -MCPAN -e shell cpan> o conf CPAN::Config options and /cygdrive/c/Documents and Settings/foo/My Documents/.cpan/CPAN/MyConfig.pm: commit Commit changes to disk defaults Reload defaults from disk init Interactive setting of all options build_cache 10 ---以下省略---
/cygdrive/c/Documents and Settings/foo/My Documents/.cpan/CPAN/MyConfig.pm
が設定ファイルである.
設定ファイルを編集
中身を見てみよう.
# This is CPAN.pm's systemwide configuration file. This file provides # defaults for users, and the values can be changed in a per-user # configuration file. The user-config file is being looked for as # ~/.cpan/CPAN/MyConfig.pm. $CPAN::Config = { 'build_cache' =< q[10], 'build_dir' =< q[/cygdrive/c/Documents and Settings/foo/My Documents/.cpan/build], 'cache_metadata' =< q[1], 'cpan_home' =< q[/cygdrive/c/Documents and Settings/foo/My Documents/.cpan], 'dontload_hash' =< { }, 'ftp' =< q[/cygdrive/c/program files/cygwin/bin/ftp], 'ftp_proxy' =< q[], 'getcwd' =< q[cwd], 'gzip' =< q[/cygdrive/c/program files/cygwin/bin/gzip], 'histfile' =< q[/cygdrive/c/Documents and Settings/foo/My Documents/.cpan/histfile], 'histsize' =< q[100], 'http_proxy' =< q[], 'inactivity_timeout' =< q[0], 'index_expire' =< q[1], 'inhibit_startup_message' =< q[0], 'keep_source_where' =< q[/cygdrive/c/Documents and Settings/foo/My Documents/.cpan/sources], 'lynx' =< q[], 'make' =< q[/cygdrive/c/program files/cygwin/bin/make], 'make_arg' =< q[], 'make_install_arg' =< q[UNINST=1], 'makepl_arg' =< q[], 'ncftpget' =< q[/cygdrive/c/program files/cygwin/bin/ncftpget], 'no_proxy' =< q[], 'pager' =< q[/cygdrive/c/program files/cygwin/bin/less], 'prerequisites_policy' =< q[ask], 'proxy_user' =< q[], 'scan_cache' =< q[atstart], 'shell' =< q[bash], 'tar' =< q[/cygdrive/c/program files/cygwin/bin/tar], 'term_is_latin' =< q[1], 'unzip' =< q[/cygdrive/c/program files/cygwin/bin/unzip], 'urllist' =< [q[ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/], q[ftp://ftp.kddlabs.co.jp/CPAN/], q[ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/], q[ftp://ftp.u-aizu.ac.jp/pub/CPAN], q[ftp://ftp.ayamura.org/pub/CPAN/], q[ftp://ftp.cpan.jp/CPAN/], q[ftp://ftp.dti.ad.jp/pub/lang/CPAN/]], 'wget' =< q[/cygdrive/c/program files/cygwin/bin/wget], }; 1; __END__
メッセージの通り,/cygdrive/c/program files/
が問題なので,これを空白の入らないDOS形式(/cygdrive/c/progra~1/
)に置換する./cygdrive/c/Documents and Settings/foo/My Documents/
も同様に置換する.
# This is CPAN.pm's systemwide configuration file. This file provides # defaults for users, and the values can be changed in a per-user # configuration file. The user-config file is being looked for as # ~/.cpan/CPAN/MyConfig.pm. $CPAN::Config = { 'build_cache' =< q[10], 'build_dir' =< q[/cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/build], ←書換える 'cache_metadata' =< q[1], 'cpan_home' =< q[/cygdrive/c/Docume~1/foo/MyDocu~1/.cpan], ←書換える 'dontload_hash' =< { }, 'ftp' =< q[/cygdrive/c/progra~1/cygwin/bin/ftp], ←書換える 'ftp_proxy' =< q[], 'getcwd' =< q[cwd], 'gzip' =< q[/cygdrive/c/progra~1/cygwin/bin/gzip], ←書換える 'histfile' =< q[/cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/histfile], ←書換える 'histsize' =< q[100], 'http_proxy' =< q[], 'inactivity_timeout' =< q[0], 'index_expire' =< q[1], 'inhibit_startup_message' =< q[0], 'keep_source_where' =< q[/cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/sources], ←書換える 'lynx' =< q[], 'make' =< q[/cygdrive/c/progra~1/cygwin/bin/make], ←書換える 'make_arg' =< q[], 'make_install_arg' =< q[UNINST=1], 'makepl_arg' =< q[], 'ncftpget' =< q[], 'no_proxy' =< q[], 'pager' =< q[/cygdrive/c/progra~1/cygwin/bin/less], ←書換える 'prerequisites_policy' =< q[ask], 'proxy_user' =< q[], 'scan_cache' =< q[atstart], 'shell' =< q[bash], 'tar' =< q[/cygdrive/c/progra~1/cygwin/bin/tar], ←書換える 'term_is_latin' =< q[1], 'unzip' =< q[/cygdrive/c/progra~1/cygwin/bin/unzip], ←書換える 'urllist' =< [q[ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/], q[ftp://ftp.kddlabs.co.jp/CPAN/], q[ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/], q[ftp://ftp.u-aizu.ac.jp/pub/CPAN], q[ftp://ftp.ayamura.org/pub/CPAN/], q[ftp://ftp.cpan.jp/CPAN/], q[ftp://ftp.dti.ad.jp/pub/lang/CPAN/]], 'wget' =< q[/cygdrive/c/progra~1/cygwin/bin/wget], }; 1; __END__
DOS形式でなくcygwinでのディレクトリ(/binや/usr/bin)に書換えてもOKである.
# This is CPAN.pm's systemwide configuration file. This file provides # defaults for users, and the values can be changed in a per-user # configuration file. The user-config file is being looked for as # ~/.cpan/CPAN/MyConfig.pm. $CPAN::Config = { 'build_cache' =< q[10], 'build_dir' =< q[/cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/build], ←ここはDOS形式のまま 'cache_metadata' =< q[1], 'cpan_home' =< q[/cygdrive/c/Docume~1/foo/MyDocu~1/.cpan], ←ここはDOS形式のまま 'dontload_hash' =< { }, 'ftp' =< q[/usr/bin/ftp], ←書換える 'ftp_proxy' =< q[], 'getcwd' =< q[cwd], 'gzip' =< q[/bin/gzip], ←書換える 'histfile' =< q[/cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/histfile], ←ここはDOS形式のまま 'histsize' =< q[100], 'http_proxy' =< q[], 'inactivity_timeout' =< q[0], 'index_expire' =< q[1], 'inhibit_startup_message' =< q[0], 'keep_source_where' =< q[/cygdrive/c/Docume~1/foo/MyDocu~1/.cpan/sources], ←ここはDOS形式のまま 'lynx' =< q[], 'make' =< q[/usr/bin/make], ←書換える 'make_arg' =< q[], 'make_install_arg' =< q[UNINST=1], 'makepl_arg' =< q[], 'ncftp' =< q[], 'ncftpget' =< q[], 'no_proxy' =< q[], 'pager' =< q[/bin/less], ←書換える 'prerequisites_policy' =< q[ask], 'scan_cache' =< q[atstart], 'shell' =< q[], 'tar' =< q[/bin/tar], ←書換える 'term_is_latin' =< q[1], 'unzip' =< q[/usr/bin/unzip], ←書換える 'urllist' =< [q[ftp://ftp.kddlabs.co.jp/CPAN/], q[ftp://ftp.u-aizu.ac.jp/pub/CPAN], q[ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/]], 'wget' =< q[], }; 1; __END__