CPAN首次启动(代理配置)

时间:2017-03-07 13:37:58

标签: perl proxy cpan

我需要运行cpan trough proxy但是当我尝试配置时我遇到了错误并且无法第一次进入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

由于

2 个答案:

答案 0 :(得分:2)

是的,这非常令人恼火。

This SO answer表明可能安装LWP(及其18个依赖项)会使问题变得更好。天哪,我很高兴我不必诉诸于此。

我遇到的问题是我已经拥有http_proxyhttps_proxy,以及我环境中设置(和导出)的 的大写版本。几乎所有其他程序(包括wgetcurl)在存在这些环境变量时都能正常工作。没必要再次设置这些,然后仍然让CPAN失败,当它明显地呼唤wget 时!

最终对我有用的是按照说明here,将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上的this article会有一个小脚本提示您输入凭据,然后设置所有相应的*_proxy*_PROXY环境变量。

就此而言,就像公共服务公告一样,请不要将重要密码放在纯文本配置文件或~/.bashrc中。

答案 1 :(得分:0)

我克服cpan代理行为的方法是在命令前加上proxychains命令。

有关代理链的详细信息:https://github.com/haad/proxychains

相关问题