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?
Related
I'm working with CPANM to interact with a proxy that requires username and password. I specified the settings when running "o conf init /proxy/ under cpan". My perception is the variables used in a unix environment for specifying proxies are not standard throughout the environment. Other unix utilities are working correctly through the proxy after setting environment variables to the correct values.
My questions are the following:
How does CPANM interfaces with any environment variables? What would they be?
Is there a relevant area of the code we can look to help remove ambiguity, I'm thinking there is an LWP interface inside of CPANM?
https://github.com/miyagawa/cpanminus/blob/devel/App-cpanminus/cpanm
####:/mnt/c/Projects$ sudo cpanm install Catalyst::Helper -v
cpanm (App::cpanminus) 1.7040 on perl 5.022001 built for x86_64-linux-gnu-thread-multi
Work directory is /home/####/.cpanm/work/1543605706.124
You have make /usr/bin/make
You have LWP 6.36
You have /bin/tar: tar (GNU tar) 1.28
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://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.
Searching install () on cpanmetadb ...
########:/mnt/c/Projects$ env | grep HTTP_proxy
HTTP_proxy=http://####:###
As far as I can see, cpanm (actually App::Cpanminus relies on HTTP::Tiny to run HTTP requests.
From the docs of HTTP::Tiny :
HTTP::Tiny can proxy both http and https requests. Only Basic proxy authorization is supported and it must be provided as part of the proxy URL: http://user:pass#proxy.example.com/.
HTTP::Tiny supports the following proxy environment variables: http_proxy or HTTP_PROXY, https_proxy or HTTPS_PROXY, all_proxy or ALL_PROXY
Hence you should try and specify the proxy username and password as part of the url, like :
$ export HTTP_PROXY=http://<user>:<password>#<url>:<port>
$ export HTTPS_PROXY=http://<user>:<password>#<url>:<port>
Also, as per documentation, the HTTP_PROXY setting is accepted by LWP::UserAgent (the primary HTTP client used by the cpan command line utility), while HTTPS_PROXY is supported by curl (fallback of cpan when LWP fails). See the LWP::UserAgent docs and the curl docs.
Hence HTTP_PROXY/HTTPS_PROXY should be the common environment variables that are supported by all CPAN clients.
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]
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
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
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