Hossein Tahmasbi
Hossein Tahmasbi

Reputation: 55

Cannot install any package in Ubuntu using dpkg, getting "package architecture does not match system"

Whenever I want to upgrade or install any package on Ubuntu 16.04 this error appears!

dpkg: error processing /var/cache/apt/archives/gcc-6-base_6.0.1-ubuntu1_amd64.deb (--unpack):

package architecture (amd64) does not match system (i386)

Errors were encountered while processing:

/var/cache/apt/archives/gcc-6-base_6.0.1-0ubuntu1_amd64.deb

E: Sub-process /usr/bin/dpkg returned an error code (1)

The uname command outputs as follows:

uname -i
x86_64

uname -a
Linux hossein 4.4.0-138-generic #164-Ubuntu SMP Tue Oct 2 17:16:02 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Upvotes: 0

Views: 23028

Answers (3)

rajpal sinh jadeja
rajpal sinh jadeja

Reputation: 1

Steps to Fix dpkg by Copying Files from a Working Machine

Download the dpkg Package On a machine where dpkg is functional, download the required dpkg package:

wget http://archive.ubuntu.com/ubuntu/pool/main/d/dpkg/dpkg_1.19.7ubuntu3_amd64.deb 

Install the ar Tool Ensure ar (from the binutils package) is installed to extract .deb files:

sudo apt-get install binutils 

Extract the .deb File Use the ar command to extract the .deb package:

ar x dpkg_1.19.7ubuntu3_amd64.deb  

This will generate the following files in your current directory:

control.tar.xz ,data.tar.xz, debian-binary 

Extract the data.tar.xz File Extract the contents of the data.tar.xz file, which includes the dpkg binary and other necessary files:

tar -xvf data.tar.xz 

Locate the Extracted Files The extracted files will include the dpkg binary, typically found in a directory like ./usr/bin/dpkg in your current working directory. Use pwd to confirm your current directory:

pwd

Copy the Files to the Problematic Machine From the working machine, transfer the extracted dpkg binary and related files to the machine where the issue exists. You can use scp or a similar file transfer tool:

scp ./usr/bin/dpkg user@problematic-machine:/path/to/destination 

Move the Files to Their Correct Locations on the Problematic Machine After transferring the files, log into the problematic machine and move the extracted files to their appropriate system locations:

sudo cp /path/to/destination/usr/bin/dpkg /usr/bin/dpkg 
sudo cp -r /path/to/destination/usr/bin/* /usr/bin/    

Verify the Installation Check if dpkg is now functional on the problematic machine:

dpkg --version

Upvotes: 0

Evandro Teixeira
Evandro Teixeira

Reputation: 370

Try to run this commands to enable support for the 64-bit userspace.

sudo apt-get update
sudo dpkg --add-architecture amd64
sudo apt-get update

and try to install the packages again. Also,you could try to run

dpkg --print-architecture

to move the investigation further.

Upvotes: 4

Evandro Teixeira
Evandro Teixeira

Reputation: 370

Your processor, as quoted, works on a different architecture than the one provided by the binary inside the package. To work around this problem, you could:

As you trying to install GCC, a simple

sudo apt-get install gcc

should work from the latest stable version. If you keep getting erros, try checking this threads:

https://askubuntu.com/questions/778318/how-do-i-install-gcc-6-latest-6-1-on-ubuntu-14-04-lts-make-c14-the-default https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu

Upvotes: 0

Related Questions