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?

5 Answers 5


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
  • 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, 2013 at 18:51

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


ls -l `dirname $(perldoc -l CPAN)`/CPAN/Config.pm

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



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.


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .