cpan安装报错Invalid host name on line 1 at *FirstTime.pm line 1857.

今天鼓捣一下CPAN,安装时出错:

root@ubuntu:~# cpan install DBI

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes]

Would you like me to automatically choose some CPAN mirror
sites for you? (This means connecting to the Internet) [yes]
Invalid host name on line 1 at /usr/share/perl/5.18/CPAN/FirstTime.pm line 1857.

分析原因,看1857是找Mirrors,但是因为之前网络出错加载Mirrors列表是空的,而Mirrors列表优先使用了Cache;

解决方法,手工选择一个Mirrors,或是等待加载完了Mirrors列表再执行一次安装,如下图:

原文地址:https://www.cnblogs.com/scue/p/4420291.html