CPAN首次启动(代理配置)

8

我需要通过代理运行cpan,但当我尝试配置时,出现错误,无法首次进入cpan。

root@srv-linux01:~# cpan

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] no

关于代理设置:
If you're accessing the net via proxies, you can specify them in the
CPAN configuration or via environment variables. The variable in
the $CPAN::Config takes precedence.

 <ftp_proxy>
Your ftp_proxy? [] http://username:password@proxyIP:Port/  <---- is ok the information?

 <http_proxy>
Your http_proxy? [] http://username:password@proxyIP:Port/  <---- is ok the information?

 <no_proxy>
Your no_proxy? []



If your proxy is an authenticating proxy, you can store your username
permanently. If you do not want that, just press ENTER. You will then
be asked for your username in every future session.

Your proxy user id? []     <---- username is needed again?


Your password for the authenticating proxy can also be stored
permanently on disk. If this violates your security policy, just press
ENTER. You will then be asked for the password in every future
session.

Your proxy password?     

在那之前,我得到了这个。

Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/MIRRORED.BY.gz
Error downloading with HTTP::Tiny: Not a CODE reference at /usr/share/perl/5.18/CPAN/HTTP/Client.pm line 112, <STDIN> line 65.

我正在使用Ubuntu Server 14.04 LTS和Perl 5.18.2。谢谢。

你尝试过将代理配置仅指定为URL,并分别提供用户名/密码吗? - Sobrique
你的ftp_proxy?[] http://ipaddress:port/你的http_proxy?[] http://ipaddress:port/还需要输入用户名和密码吗?是的,我输入了但是仍然得到相同的结果... - Emiliano Cagliari
1
你不能像这样使用CPAN安装吗:export http_proxy=http://httpproxy.test.com:8080/; export https_proxy=$http_proxy - AbhiNickz
嗨,AbhiNickz我得到了这个:使用HTTP::Tiny获取: http://www.perl.org/CPAN/MIRRORED.BY.gz 使用HTTP::Tiny下载时出错:在/usr/share/perl/5.18/CPAN/HTTP/Client.pm的第112行,<STDIN>的第2行不是CODE引用。 - Emiliano Cagliari
2个回答

8

嗯,这真是让人恼火。

这个Stack Overflow的答案建议也许安装LWP(和它的18个依赖项)可以让问题得到改善。天啊,我很高兴我没有不得不采取那种方法。

我遇到的问题是,我已经在我的环境中设置并导出了http_proxyhttps_proxy和它们的大写版本。当这些环境变量存在时,几乎所有其他程序(包括wgetcurl)都可以正常工作。不必再次设置这些变量,并且当CPAN显然在调用wget时仍然失败,这毫无意义!

最终为我工作的是按照这里的指示,将CPAN的http_proxy配置设置为空字符串。(我先前还手动编辑过〜/ .cpan / CPAN / MyConfig.pm以删除代理用户名和密码设置。)

$ cpan  # or perl -MCPAN -e shell
cpan[1]> o conf http_proxy ""
cpan[2]> o conf ftp_proxy ""
cpan[3]> o conf proxy_user ""
cpan[4]> o conf proxy_pass ""
cpan[5]> o conf commit
cpan[6]> q

$ # I have a shell function that does basically this
$ export http_proxy="http://user:pass@proxyserver:8080"
$ for v in HTTP_PROXY https_proxy HTTPS_PROXY ftp_proxy FTP_PROXY; do
> export $v="$http_proxy"
> done

$ cpan i Devel::Repl   # or whatever

然后可以假设,wget 只是在调用 cpan 之前使用了在定义的环境变量,这当然是有效的。如果您有需要身份验证的代理,请参考 Arch Wiki 上的此文章中的一个小脚本,该脚本将提示您输入凭据,然后设置所有适当的*_proxy*_PROXY环境变量。
关于这一点,作为公共服务通告,请不要在纯文本配置文件或您的~/.bashrc中存储重要密码。

这实际上可以正常工作,但它会在安装过程中的每个wget请求中要求代理身份验证。但我可以接受。 - X3MBoy
1
@X3MBoy 可能这根本不是你的问题,但我还是要强调一下,确保你已经“导出”了变量。子shell 不会继承环境变量的值,除非你明确地这样做。 - TheDudeAbides
在我的情况下,这解决了问题 - Pablo Bianchi

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接