8

So I ran into a simple little problem. I wasn't connected to the internet and started cpan. It started to configure for the first time and then when I realised a few seconds later that the internet wasn't connected I hit Ctrl + C

When I connected to the internet and brought CPAN up again, it asked me to continue from where is left, but prompted me for a WHOLE lot of configuration options. I left them to default.

It then asked me for a mirror URL, I think I typed it incorrectly. Now cpan doesn't work at all!!

I would like to reset to the typical first start I'm used to where it will ask to configure everything for me.

I looked at this perlmonks post which suggested deleting /etc/perl/CPAN/Config.pm but it doesn't exist for me. /etc/perl doesn't exist itself.

Question: I'm on CentOS 6.4, how do I reset cpan?

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
gideon
  • 353
  • 3
  • 6
  • 17

5 Answers5

11

I believe cpan maintains its files in the directory of the user that ran it. So if it was root then they'd be in /root/.cpan. You can just blow this directory away completely.

Alternatively you can re-run the "wizard" that asks you all those CPAN questions using this command:

$ cpan o conf init
cjm
  • 26,740
  • 12
  • 88
  • 84
slm
  • 363,520
  • 117
  • 767
  • 871
  • Thanks for your answer. I deleted the directory `/root/.cpan` cpan still doesn't give me that first launch message, when I did `sudo cpan` then `cpan> o conf init` it ran all the regular auto configuration **except** the urllist config, but prompted me to do that. When I did it let me select a continent, country and gave me the right list of mirrors. It's all working now :D – gideon Jul 11 '13 at 18:51
2

Removing /root/.cpan certainly helps, but if you want to go back to the first launch message, you need to remove CPAN/Config.pm. To find out where it is, try:

perldoc -l CPAN

i.e.:

ls -l `dirname $(perldoc -l CPAN)`/CPAN/Config.pm
TPS
  • 2,483
  • 5
  • 27
  • 45
Joao Costa
  • 121
  • 2
1

replace Config.pm with fixed version

wget http://search.cpan.org/CPAN/authors/id/A/AN/ANDK/CPAN-2.16.tar.gz
tar -zxvf CPAN-2.16.tar.gz
sudo mkdir  /usr/share/perl5/CPAN/ -p
sudo cp ./CPAN-2.16/lib/CPAN/FirstTime.pm /usr/share/perl5/CPAN/FirstTime.pm

source

Thomas
  • 6,242
  • 8
  • 26
  • 32
Mohannd
  • 131
  • 6
0

On my shared hosting server, there is also a ~/.cpan/CPAN/MyConfig.pm file. Deleting the whole ~/.cpan folder did the job for me. Deleting /usr/share/perl5/CPAN/Config.pm requires root privilege so no can do for me.

This code works for me to reset and re-run cpan setup with no output (extracted from my sslcert cron script).

if [ -d ~/.cpan ]; then rm -fR ~/.cpan ; echo y | cpan > /dev/null 2>&1; fi

Same line also ran on my ubuntu desktop pc.

5p0ng3b0b
  • 121
  • 4
-1

delete /usr/share/perl5/CPAN/Config.pm and then run CPAN again

TPS
  • 2,483
  • 5
  • 27
  • 45