This warning appears when attempting to remove your system's native architecture with dpkg. You can only remove foreign (additional) architectures that were added via dpkg --add-architecture, not the primary system architecture.
Every Linux system has one native architecture (the CPU architecture it runs on, like amd64 for 64-bit systems). dpkg distinguishes between this native architecture and "foreign" architectures that have been explicitly added to support multiarch (running 32-bit and 64-bit binaries together). The warning "cannot remove non-foreign architecture" indicates you're trying to remove your system's native architecture, which is not allowed. Foreign architectures (like i386 on an amd64 system) can be added and removed, but the native architecture is permanent and essential for your system to function.
Run dpkg --print-architecture to see your system's native architecture. This is the one you cannot remove.
dpkg --print-architectureOn most modern 64-bit systems, this will output amd64. This is your native architecture and cannot be removed.
If you want to remove an architecture, first check which foreign architectures have been added to your system:
dpkg --print-foreign-architecturesIf the output is empty, no foreign architectures have been added. Only architectures listed here can be removed.
In a multiarch setup:
- Native architecture: The CPU architecture of your hardware (e.g., amd64). Listed by dpkg --print-architecture. This cannot be removed.
- Foreign architectures: Additional architectures added to support multiarch (e.g., i386 on amd64). Listed by dpkg --print-foreign-architectures. These can be added and removed.
Common foreign architectures include i386 (32-bit) on amd64 (64-bit) systems, or arm64 on amd64 systems.
To remove a foreign architecture (not your native one), use:
sudo dpkg --remove-architecture i386Before doing this, ensure no packages of that architecture are installed. You may need to uninstall them first:
sudo apt-get purge ".*:i386"
sudo dpkg --remove-architecture i386Note: Replace i386 with the actual foreign architecture you want to remove.
The native architecture is hardcoded into dpkg's database and cannot be changed without reinstalling the system. Attempting to remove it is a protection mechanism to prevent system damage. If you genuinely need to change your system's primary architecture, you would need to perform a full OS reinstall targeting the desired architecture. Multiarch is primarily designed for 32-bit compatibility (i386) on 64-bit (amd64) systems, or for cross-architecture development.
E: Cannot set to hold: package 'package-name' is not installed
How to fix "Cannot set to hold" error when package is not installed in APT
debconf: unable to initialize frontend: Dialog
How to fix "debconf: unable to initialize frontend: Dialog" in APT
E: Could not connect to proxy server
Could not connect to proxy server
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt