Long story short: I made a pretty ridiculous stupid error when trying to configure CPAN that resulted in me having two half-versions of Perl, both of which are missing important packages. In particular, these half-versions don't have what's needed in order to make apt-get or CPAN work properly, which would normally be the way I'd think to get the packages to complete Perl.

Currently, the only way I can think of to fix this relies on the fact I happen to have a Debian virtual machine that I haven't messed with (so therefore doesn't have horribly broken Perl), so I could theoretically remove both half versions of Perl from my main machine and then paste a copy of working Perl from the virtual machine. Are there any other reasonable methods for this kind of thing?

  • It would be much simpler if you could post things like error messages, and suchlike. For instance, when you run apt-get, could you present us the error message? It might be just something like a simple path error, etc. – polemon Jul 14 '16 at 4:17
  • Unfortunately I don't have access to the computer at the moment and can't copy the exact error, but it says for both apt-get and cpan that I'm lacking at least one module that is specific to Debian; further checks verify this is indeed the case since I can't find the files for the module where they ought to be. – QuillAndSaber Jul 14 '16 at 4:50

Perl in Debian is split into several parts. One of these parts, the perl-base package, is part of the set of "essential" packages. Debian defines these essential packages as "will always be installed on a debian system". Packages can assume they will be available, even if they do not have any form of dependency declared on them. If you remove one of them, then things are likely to go horribly wrong. For that reason, if you try to do so, dpkg will complain very loudly and ask you to confirm that you want to break your system by literally entering the phrase Yes, do as I say! , with punctuation and everything. Never do this; you will get the system in a state that it is highly unlikely to recover from by itself.

If you did, then your system is now broken. Do not despair, however; it is still possible to fix it.

  • First, run dpkg -l perl-base to confirm that you are indeed missing the perl-base package. If the output of that command starts with ii on the line that contains perl-base, then this is not the problem and you have a different problem. In that case, post the exact error messages you get when trying to run some apt command. Otherwise debugging becomes a crystal ball problem.
  • download the perl-base package for whichever version of debian you are running.
  • Next, run ar x perl-base*deb. This will create three files in the current working directory: debian-binary, data.tar.gz, and control.tar.gz. Note: data.tar.gz could also be data.tar.xz. If you don't have ar installed on your system, you can run this step on a different system, and copy the resulting files to the broken machine (any UNIX-like machine will work, doesn't have to be a debian box).
  • The data tarball contains the files this package wants to put on the filesystem. Unpack it in the right location with the following command: tar xvaf data.tar.* -C /. The -C / bit is the important part here; it tells tar to unpack relative to the root directory of the filesystem.
  • Once you're here, the missing files are back on your system, and dpkg as well as apt will work again. However, you're not done yet; at this point, the files are there, but because of the way you've "installed" perl-base, dpkg will think it's not there and may start doing weird things. For that reason, it's necessary to install it "again", by running dpkg -i perl-base*deb.

Everything should be fixed now. Next time, if dpkg tells you to enter that phrase, do the smart thing and say 'no' ;-)

  • ... and also don't mess with /usr/local (or wherever Debian installs its packages). – Kusalananda Jul 16 '16 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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