例えば、依存関係にあるモジュールがインストールされていないと、下のような選択肢が出てくる。この場合に自動的にyesを選択して欲しい。
Warning: prerequisite HTML::TreeBuilder::LibXML 0.04 not found.
Writing Makefile for Web::Scraper
---- Unsatisfied dependencies detected during ----
---- MIYAGAWA/Web-Scraper-0.31.tar.gz ----
HTML::TreeBuilder::LibXML [requires]
Shall I follow them and prepend them to the queue
of modules we are processing right now? [yes]
これを解決するには、yesコマンドを使ったり環境変数を変えたりする方法があるようだ。しかし、ここではcpanのprerequisites_policy変数を変える方法をとってみる。
# cpan
cpan[3]> o conf prerequisites_policy follow
prerequisites_policy [follow]
Please use 'o conf commit' to make the config permanent!
cpan[4]> o conf commit
commit: wrote '/etc/perl/CPAN/Config.pm'
prerequisites_policy変数をfollowにしておくと、選択肢のデフォルトを自動的に選択してくれる。(Policy on building prerequisites = follow デフォルト選択、ask 尋ねる、ignore 依存モジュールのインストールを行わない)commitすると、変更内容が記憶される。一時的に変更する場合はcommitしない。
例えば、下のような選択肢が出てきた場合に自動的にnを選択して欲しい。
============================================= Prompts may be bypassed by running: /usr/bin/perl Makefile.PL --default ============================================= Some of POE's tests require a functional network. You can skip these tests if you'd like. Would you like to skip the network tests? [n]
これはどうする?
CPAN.pm: Going to build M/MI/MIYAGAWA/Web-Scraper-0.31.tar.gz
*** Module::AutoInstall version 1.03
*** Checking for Perl dependencies...
*** Since we're running under CPAN, I'll just let it take care
of the dependency's installation later.
[Core Features]
- Scalar::Util ...loaded. (1.22)
- HTML::TreeBuilder::XPath ...loaded. (0.11 >= 0.08)
- HTML::TreeBuilder ...loaded. (3.23 >= 3.23)
- XML::XPathEngine ...loaded. (0.12 >= 0.08)
- HTML::Selector::XPath ...loaded. (0.03 >= 0.03)
- LWP ...loaded. (5.834 >= 5.827)
- HTML::Entities ...loaded. (3.64)
- HTML::Tagset ...loaded. (3.20)
- UNIVERSAL::require ...loaded. (0.13)
- URI ...loaded. (1.52)
- YAML ...loaded. (0.71)
[LibXML]
- HTML::TreeBuilder::LibXML ...missing. (would need 0.04)
==> Auto-install the 1 optional module(s) from CPAN? [y]