Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I safely clean up root's .cpan folder?

Tags:

perl

I have a development class Linux server which has been used for a great deal of Perl code creation and testing. On this machine is a /root folder, part of the / partition, and in there is a .cpan folder - which is currently consuming almost 1TB of disk space. We have been having issues with free space on the / partition and I'd like to 'clean up' this .cpan folder. The build sub-directory has 100's of sub-folders, which appear to be already installed CPAN modules. Is it safe to delete those? Is there an option/command I can use inside of cpan to check or assist in the clean up?

I've checked several man pages and on-line searches, but I'm not certain what could be removed without impacting the system. Are there setting I could change that would keep this folder clean in the future?

Thanks.

like image 907
Jim Black Avatar asked Oct 16 '16 17:10

Jim Black


1 Answers

Short answer: Yes, you can delete that ~root/.cpan/build folder without affecting your system.

On the other hand: It's not recommended that user root has a .cpan folder at all. Usually you would install modules as some other (non-root) user. cpan then complains about not being able to install the modules in question and asks what to do. sudo is one option, I usually choose that. cpan will then compile and test new modules in that user's $HOME/.cpan and when it comes to installation it'll ask you for root's (or your) password (depends on settings in /etc/sudoers).

There's also a setting for the maximum size of the ~/.cpan/build directory. Run:

$ cpan
$ o conf build_cache

and see what the current setting is. For me it's [100] which means 100 MB. Type (e.g.)

$ o conf build_cache 50
$ o conf commit

to set it to 50 MB. The cpan shell will instruct you further.

I'm not perfectly sure but I think you need to run the clean command afterwards to actually reduce the size of ~/.cpan/build, i.e. (in the cpan shell):

$ clean
like image 142
PerlDuck Avatar answered Oct 26 '22 02:10

PerlDuck