When I was trying to install build-essential (for gcc compiler), I keep getting a weird error that says “The HTTP server sent an invalid Content-Range header”. I’ve tried many times as I suspected it’s because of the spotty wifi connection and even tried installing via LAN to no avail. Numerous websites just say retry or use synaptics package manager but all failed. One even suggested that maybe I’m accessing the repository from a Muslim country or from China which of course, is not true and does not have anything to do with my problem. That’s the case until I found this post.
To be clear, here’s the actual problem when I invoke sudo apt-get install build-essential.
After this operation, 14.8MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Err http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main binutils 2.20.1-3ubuntu7
The HTTP server sent an invalid Content-Range header [IP: 184.108.40.206 80]
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/b/binutils/binutils_2.20.1-3ubuntu7_i386.deb The HTTP server sent an invalid Content-Range header [IP: 220.127.116.11 80]
The solution is to remove the files in the following folder.
sudo rm /var/cache/apt/archives/partial/*
After that, I just reinstalled build-essential and everything went fine. I hope this will help you because it did to me. Man, it took me several days. Thanks to Raz.