【问题标题】:CPAN first launch (Proxy Configuration)CPAN 首次启动(代理配置)
【发布时间】:2017-07-27 17:59:02
【问题描述】:

我需要通过代理运行 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,并分别给用户/通行证?
  • 喜欢你的 ftp_proxy? []ipaddress:port你的http_proxy? [] ipaddress:port 和用户并通过之前?是的,我也一样……
  • 你不能像这样使用 CPAN 安装:export http_proxy=http://httpproxy.test.com:8080/; export https_proxy=$http_proxy
  • 嗨 AbhiNickz 我明白了;使用 HTTP::Tiny 获取:perl.org/CPAN/MIRRORED.BY.gz 使用 HTTP::Tiny 下载时出错:不是 /usr/share/perl/5.18/CPAN/HTTP/Client.pm 第 112 行, 第 2 行的代码参考。跨度>

标签: perl proxy cpan


【解决方案1】:

我为克服 cpan 代理行为所做的就是在命令前面加上 proxychains 命令。

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

【讨论】:

    【解决方案2】:

    是的,这很令人恼火。

    This SO answer 建议安装 LWP(及其 18 个依赖项)可能会改善问题。天哪,我很高兴我不必诉诸于此。

    我遇到的问题是,我的环境中已经有http_proxyhttps_proxyboth 的大写版本。当这些环境变量存在时,几乎所有其他程序(包括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中。

    【讨论】:

    • 这实际上工作正常,但它要求在安装中的每个 wget 中进行代理身份验证。但我可以忍受它
    • @X3MBoy 可能这根本不是你的问题,但无论如何我应该强调以确保你有exported 变量。除非您明确这样做,否则子外壳不会继承环境变量的值。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-09
    相关资源
    最近更新 更多