You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法从CPAN安装模块:‘could not find release’错误求助

问题描述

通过代理访问外网环境,执行cpanm -v App::cpanminus时持续提示找不到App::cpanminus模块,但该模块实际存在于CPAN。已尝试多日仍无法解决,以下是相关操作日志及配置信息,恳请提供排查建议:

操作日志与配置信息

# export HTTP_PROXY="http://proxy.mycompany.com:8080"
[root@vm]# cpanm -v App::cpanminus
cpanm (App::cpanminus) 1.7047 on perl 5.026003 built for x86_64-linux-thread-multi
Work directory is /root/.cpanm/work/1728941689.1094777
You have make /usr/bin/make
You have LWP 6.72
You have /usr/bin/tar: tar (GNU tar) 1.30
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching App::cpanminus () on cpanmetadb ...
! Finding App::cpanminus on cpanmetadb failed.
! Could not find a release matching App::cpanminus on MetaCPAN.
Searching App::cpanminus on mirror http://www.cpan.org ...
Downloading index file http://www.cpan.org/modules/02packages.details.txt.gz ...
! Finding App::cpanminus () on mirror http://www.cpan.org failed.
! Couldn't find module or a distribution App::cpanminus
Expiring 1 work directories.

cpan[3]> o conf /proxy/
$CPAN::Config options from /root/.cpan/CPAN/MyConfig.pm:

ftp_proxy          [http://proxy-uat.mycompnay.com:8080]
http_proxy         [http://proxy-uat.mycompnay.com:8080]
no_proxy           []
proxy_pass         undef
proxy_user         []



# wget -e use_proxy=yes -e http_proxy=http://proxy.mycompany.com:8080 https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7047.tar.gz
--2024-10-14 21:39:50--  https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7047.tar.gz
Resolving proxy-uat.mycompany.com (proxy-uat.mycompany.com)... 10.202.192.1, 10.202.192.32
Connecting to proxy-uat.mycompany.com (proxy-uat.mycompany.com)|10.202.192.1|:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 316779 (309K) [application/x-gzip]
Saving to: ‘App-cpanminus-1.7047.tar.gz

App-cpanminus-1.704 100%[===================>] 309.35K  --.-KB/s    in 0.03s   

2024-10-14 21:39:50 (11.6 MB/s) - ‘App-cpanminus-1.7047.tar.gz’ saved [316779/316779]

[root@vm]# ls -l App-cpanminus-1.7047.tar.gz 
-rw------- 1 root root 316779 Jul 30  2023 App-cpanminus-1.7047.tar.gz

# cat ~/.wgetrc 
use_proxy=yes
http_proxy=http://proxy-uat.mycompany.com:8080
https_proxy=http://proxy-uat.mycompany.com:8080
ftp_proxy=http://proxy-uat.mycompany.com:8080

排查建议

  • 统一代理配置:
    当前设置的HTTP_PROXY环境变量是proxy.mycompany.com:8080,但CPAN配置文件和.wgetrc中使用的是proxy-uat.mycompany.com:8080,域名不一致可能导致cpanm无法正确走代理。建议统一所有代理配置为同一个地址,并补充HTTPS_PROXY环境变量(cpanm访问MetaCPAN需要HTTPS代理):
    export HTTP_PROXY=http://proxy-uat.mycompany.com:8080
    export HTTPS_PROXY=http://proxy-uat.mycompany.com:8080
    
  • 手动指定CPAN镜像重试:
    cpanm默认依赖的cpanmetadb可能无法通过公司代理正常访问,尝试强制指定官方CPAN镜像执行安装:
    cpanm -v --mirror http://www.cpan.org App::cpanminus
    
  • 直接安装已下载的包:
    既然已经成功下载了App-cpanminus-1.7047.tar.gz,可以跳过网络查找步骤,手动编译安装:
    tar zxf App-cpanminus-1.7047.tar.gz
    cd App-cpanminus-1.7047
    perl Makefile.PL
    make && make install
    
  • 清理cpanm缓存:
    cpanm可能缓存了过期的CPAN索引,清理缓存后再重试安装:
    rm -rf ~/.cpanm
    
  • 验证LWP的代理访问能力:
    cpanm依赖LWP库进行网络请求,测试LWP是否能正常访问cpanmetadb:
    perl -MLWP::Simple -e 'print get("https://cpanmetadb.plackperl.org/v1.0/package/App::cpanminus")'
    
    如果没有返回内容,说明LWP的代理配置存在问题,需要检查LWP相关的配置文件或环境变量。

内容的提问来源于stack exchange,提问作者XCodeHacker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 07:45:13