How to prevent cpan fron using proxy? - perl

My knowledge of perl is limited to running commands. I have managed to come up with a shell script to output the gav of a pom.xml, using xpath as follows:
xpath pom.xml '//project/artifactId/text()'
On a new machine right now, this does not work because I do not have the XPath.pm installed:
Can't locate XML/XPath.pm in #INC (#INC contains: /usr/lib/perl5/site_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.14 /usr/lib/perl5/vendor_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.14 /usr/lib/perl5/5.14/x86_64-cygwin-threads /usr/lib/perl5/5.14 .)
I seem to remember installing XPath using cpan so I tried the following command, blindly:
cpan XPath
This is probably not the correct command to use, but I think that is unrelated to the issue I am facing. The command gives following error:
Going to read '/home/****/.cpan/Metadata'
Database was generated on Mon, 25 Aug 2014 00:41:02 GMT
Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/authors/01mailrc.txt.gz
HTTP::Tiny failed with an internal error: Could not connect to 'proxy:8080': IO::Socket::INET: Bad hostname 'proxy' at /usr/lib/perl5/5.14/HTTP/Tiny.pm line 139
Proxy authentication needed!
(Note: to permanently configure username and password run
o conf proxy_user your_username
o conf proxy_pass your_password
)
Username: C-c C-c
Why is HTTP::Tiny looking for host proxy? We do have a corporate proxy with hostname proxy but that is needed only when I am on corporate network or VPN, neither of which is case right now.
How do I convince HTTP::Tiny to connect directly to internet? I do not have an envvar named http_proxy or HTTP_PROXY set.

While the environment variable is used, cpan first checks its configuration.
To view: o conf http_proxy
To clear: o conf http_proxy ''
Don't forget to use o conf commit to make the change permanent.

CPAN uses HTTP:Tiny to download info about the module you are asking for. It is lightweight so it runs fast.
Either CPAN has not been configured, or the cpan found on your path is configured to use the proxy. Determine the location of the CPAN program you are executing and proceed from there.

This msg Can't locate XML/XPath.pm in #INC (#INC contains: /usr/lib/perl5/site_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.14 /usr/lib/perl5/vendor_perl/5.14/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.14 /usr/lib/perl5/5.14/x86_64-cygwin-threads /usr/lib/perl5/5.14 .) shows that module is not installed.
If you are on windows and using a proxy setting. You can use these commands to install module from ppm or cpan. Open a command prompt and run these commands :
set http_proxy=http://xxx.xxx.xxx.x:yyyy (xxx is your system proxy and yyyy is port)
set http_proxy_user=username (login username)
set http_proxy_pass=password (login password)
To install a module from cpan type:
cpan install modulename

The error occurs because you have set http_proxy variable to direct IP, Instead, put http_proxy=http://ipaddress , then it will work

Related

Strawberry Perl module installation issues

Following an equipment 'upgrade' at work, which is a Windows environment, I had to reinstall Perl. ActiveState never worked and I was able to install Strawberry, which fortunately comes with some necessary modules included, such as Excel parsers and writers. The problem is when I try to add additional needed modules. As I understand there are 2 ways to do this: Either download the tarball and build it manually or use cpan.
The first solution requires gmake which is disallowed/blocked by group policy
cpan also fails:
>cpan install Tk
Loading internal logger. Log::Log4perl recommended for better logging CPAN: LWP::UserAgent loaded ok (v6.52) Fetching with LWP: http://www.cpan.org/authors/01mailrc.txt.gz LWP failed with code[407] message[Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )]
Proxy authentication needed! (Note: to permanently configure username and password run o conf proxy_user your_username o conf proxy_pass your_password )
I also read somewhere that ppm build also works with strawberry, but I have been unable to find ppds.
Any suggestions?

Error while using cpan command line

I am getting the below errors while using cpan command line:
Reading 'C:\Perl64\cpan\sources\modules\02packages.details.txt.gz'
Warning: Your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz does not
contain a Line-Count header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
CPAN: Time::HiRes loaded ok (v1.9741)
Warning: Your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz does not
contain a Last-Updated header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
........Could not split line[" return \"DIRECT\";"]
Could not split line[""]
........Could not split line[" return \"DIRECT\";"]
Could not split line[""]
Giving up parsing your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz,
too many errors
I was trying to install cpanm using cpan App::cpanminus command in command prompt.
I am behind a firewall and have configured the pac file in the http_proxy env variable also. I am using ActivePerl.
return "DIRECT"; is something you will often see in a proxy configuration file, so that's what you probably downloaded into 02packages.details.txt.gz before your proxy was set up correctly.
Once you're sure that your proxy is set up correctly, delete this file and run cpan again. Then cpan will download a fresh copy of the package file.
Once you're sure that your proxy is set up correctly ...
cpan has proxy settings that may need to be configured to get this working.
Run o conf /proxy/ from the cpan prompt to see them.
On my work machine, for example, I have the settings
http_proxy [http://proxymachine.mycompany.com:82]
no_proxy [localhost,127.0.0.1,internalsite.mycompany.com]

CPAN first launch (Proxy Configuration)

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 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
On proxy settings:
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?
And before that i get this.
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.
Im using Ubuntu Server 14.04 LTS and Perl 5.18.2
Thanks
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

Install perl-Mcrypt on Centos 6.5

i need to install perl-Mcrypt On CentOs6.5/32bit.
with cpan I get the following error:
[root#name ~]# cpan
cpan[1]>install Mcrypt
CPAN: Storable loaded ok (v2.20)
LWP not available
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp31072'. Giving up on it. at /usr/share/perl5/CPAN/Index.pm line 225
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp31072'. Giving up on it. at /usr/share/perl5/CPAN/Index.pm line 225
No external ftp command available
Client not fully configured, please proceed with configuring.
You have not configured a urllist and do not allow connections to the
internet to get a list of mirrors. If you wish to get a list of CPAN
mirrors to pick from, use this command
o conf init connect_to_internet_ok urllist
If you do not wish to get a list of mirrors and would prefer to set
your urllist manually, use just this command instead
o conf init urllist
LWP not available
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp31072'. Giving up on it. at /usr/share/perl5/CPAN/Index.pm line 225
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp31072'. Giving up on it. at /usr/share/perl5/CPAN/Index.pm line 225
No external ftp command available
How to fix it?
(also I dont Know How to Config Cpan)
Thanks.
Its might be a problem of proxy setting. set up http_proxy variable in cpan.
You can see here about configuration of web proxy (may be its not a right way but you can get some idea from here)
http://www.thesysadminhimself.com/2013/08/configuring-web-proxy-on-centos.html

Installing strawberry perl in windows

I have installed perl in windows 7 and configured the proxy (http & ftp) as at How do I install a module? Strawberry Perl issues by Axeman, replacing proxy with my lan proxy IP and port respectively. However, when I run cpanm App::cpanminus, it returns a message for proxy authentication which has faile. Its requesting for a username.
you need to set the http_proxy environment variable in the form:
http_proxy=http://user:password#host:port/
Otherwise just use the cpan client.
Edit: 2012-08-29
If you do not have the proxy username and password, you are not getting out through that proxy regardless of the client software.