8

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.

0

3 Answers 3

9

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
0
6

Just delete it.

All of the files in that directory are temporary files generated while installing or upgrading modules from CPAN. They are not required after the install is complete.

You may want to teach your system administrator about the cpanm tool, which is a bit easier to use, and does some automatic cleanup of its temporary files.

-1

there is a process that will have high cpu usage if you delete the cpan folder. I forgot what process it is, but it scans files

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jan 10, 2022 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.