i need to run cpan trough proxy but when i try to configure i got errors and cant enter to cpan for the first time
root@srv-linux01:~# cpan
CPAN.pm requires
Yeah, this is pretty exasperating.
This SO answer suggests that maybe installing LWP (and its 18 dependencies) makes the problem better. Gosh, I'm glad I didn't have to resort to that.
The issue I had with this was that I already had http_proxy
, https_proxy
, and the uppercase versions of both of those set (and exported) in my environment. Just about every other program (including wget
and curl
) is works fine when these environment variables are present. It made no sense to have to set these again, and then still have CPAN fail, when it's obviously calling out to wget
!
What did finally work for me was to follow the instructions here, setting the CPAN http_proxy
config setting to the empty string. (I also had previously removed the proxy username and password settings by hand-editing ~/.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
Then, presumably, wget
was just using the environment variables defined before calling cpan
, which of course works fine. If you have a proxy that requires authentication, this article on the Arch wiki has a little script that will prompt you for the credentials, and then set all the appropriate *_proxy
and *_PROXY
environment variables.
On that note, just as a public service announcement, please don't put important passwords in plain-text configuration files or in your ~/.bashrc
.
what I did to overcome cpan proxy behavour is to prefix the command with proxychains command.
Details about proxychains: https://github.com/haad/proxychains