How to fix E: Unable to determine file size for /var/cache/apt/srcpkgcache.bin - fstat (9: Bad file descriptor) in APT
The srcpkgcache.bin file in APT's cache directory has become corrupted, preventing APT from reading source package metadata. This is typically resolved by clearing the corrupted cache files and rebuilding the cache.
Quick fix
Fixes E: Unable to determine file size for /var/cache/apt/srcpkgcache.bin - fstat (9: Bad file descriptor)
sudo rm /var/cache/apt/*.bin- Clear the APT cache files
- Update the APT package list
- Verify the fix by listing packages
- If the issue persists, perform a deeper cache clean
sudo rm /var/cache/apt/*.binE: Unable to determine file size for /var/cache/apt/srcpkgcache.bin - fstat (9: Bad file descriptor)
What this error means
This error occurs when APT attempts to read the source package cache file (srcpkgcache.bin) but encounters a corrupted or inaccessible file. The "Bad file descriptor" error indicates that the file exists but cannot be read due to corruption or permission issues. The srcpkgcache.bin file is part of APT's internal cache system that stores parsed package information from remote sources to avoid reparsing package files on subsequent operations.
Typical symptoms
- apt-get update fails with "Unable to determine file size" error
- APT commands hang or crash when accessing package information
- Package installation or updates fail silently
- Synaptic Package Manager or other APT frontends refuse to open
- Error occurs even on fresh system configurations
Common causes
- Corrupted cache files due to unexpected system shutdown or disk errors
- Filesystem issues or disk corruption affecting the /var/cache/apt/ directory
- Permission problems preventing APT from reading cache files
- Incomplete previous apt-get operation that was interrupted
- APT package manager bug resulting in corrupted cache during normal operations
How to fix "E: Unable to determine file size for /var/cache/apt/srcpkgcache.bin - fstat (9: Bad file descriptor)"
Remove all binary cache files (.bin files) from the APT cache directory. APT will automatically regenerate these files on the next update:
sudo rm /var/cache/apt/*.binThis removes both pkgcache.bin and srcpkgcache.bin, which are temporary files that APT recreates as needed.
Rebuild the APT cache by running update. This will download the latest package list from repositories and regenerate the cache files:
sudo apt-get updateWatch for any new errors during this process. If update completes successfully, the corrupted cache has been cleared.
Confirm that APT can now access package information properly:
apt-cache search . # Lists all available packagesIf this command completes without errors, the cache corruption is resolved. You can now proceed with normal apt-get operations.
If basic cache clearing doesn't resolve the issue, clean additional APT-related files:
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get update- apt-get clean removes all cached .deb packages from /var/cache/apt/archives/
- apt-get autoclean removes only outdated .deb packages that are no longer available in repositories
- Then rebuild the cache with apt-get update
Advanced notes
For systems with persistent cache corruption, investigate underlying filesystem health using fsck (filesystem check). Unexpected shutdowns, disk I/O errors, or SD card issues (on Raspberry Pi) can cause cache corruption. On Docker containers, ensure volumes mounted at /var/cache/apt/ support proper file operations. The srcpkgcache.bin file is generated by APT's internal gencaches process and is safe to delete—APT will regenerate it automatically. If corruption occurs repeatedly, consider running a full filesystem check and verifying hard disk health with smartctl.
Frequently asked questions
- What does "E: Unable to determine file size for /var/cache/apt/srcpkgcache.bin -" mean?
- bin) but encounters a corrupted or inaccessible file. The "Bad file descriptor" error indicates that the file exists but cannot be read due to corruption or permission issues. bin file is part of APT's internal cache system that stores parsed package information from remote sources to avoid reparsing package files on subsequent operations.
- How do I fix "E: Unable to determine file size for /var/cache/apt/srcpkgcache.bin -"?
- The srcpkgcache.bin file in APT's cache directory has become corrupted, preventing APT from reading source package metadata. This is typically resolved by clearing the corrupted cache files and rebuilding the cache.
- What causes "E: Unable to determine file size for /var/cache/apt/srcpkgcache.bin -"?
- Corrupted cache files due to unexpected system shutdown or disk errors Filesystem issues or disk corruption affecting the /var/cache/apt/ directory Permission problems preventing APT from reading cache files
- Is the "E: Unable to determine file size for /var/cache/apt/srcpkgcache.bin -" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚APT Official Documentation
- 📖Debian Manual Pages - apt-cache(8)(Official Docs)
- 📖Debian Administrator's Handbook - The apt-cache Command(Official Docs)
- 🐙
- 📝