0

Problem solved..by changing the source for 16.04 to the one for 18.04.


I have met some dependency problems when trying to install applications with apt:

$ sudo apt install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.  
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 vim : Depends: vim-common (= 2:7.4.1689-3ubuntu1.2) but 2:8.0.1453-1ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.

When I tried to install aptitude and then install vim by aptitude, to solve the dependency problem, it told me that apt would be removed:

$ sudo apt-get install aptitude
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  aptitude-common libboost-iostreams1.58.0 libcwidget3v5 libsigc++-2.0-0v5
  libxapian22v5
Suggested packages:
  apt-xapian-index aptitude-doc-en | aptitude-doc debtags tasksel
  libcwidget-dev xapian-tools
The following packages will be REMOVED:
  apt apt-utils ubuntu-desktop ubuntu-minimal ubuntu-release-upgrader-gtk
  update-manager update-notifier update-notifier-common
The following NEW packages will be installed:
  aptitude aptitude-common libboost-iostreams1.58.0 libcwidget3v5
  libsigc++-2.0-0v5 libxapian22v5
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  apt
0 upgraded, 6 newly installed, 8 to remove and 13 not upgraded.
Need to get 2,974 kB of archives.
After this operation, 4,842 kB of additional disk space will be used.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
 ?] ^C

Then when I tried to install vim via aptitude, it showed the error that it couldn't find some folder of apt...

I have asked my roommate and he said apt and aptitude don't conflict with each other! So is it true that I can install aptitude without removing apt? and how?

Updated after running apt -f install:

cky@cky:~$ sudo apt update
Hit:1 https://mirrors.ustc.edu.cn/ubuntu xenial InRelease
Hit:2 https://mirrors.ustc.edu.cn/ubuntu xenial-security InRelease
Hit:3 https://mirrors.ustc.edu.cn/ubuntu xenial-updates InRelease
Hit:4 https://mirrors.ustc.edu.cn/ubuntu xenial-backports InRelease
Reading package lists... Done                     
Building dependency tree       
Reading state information... Done
13 packages can be upgraded. Run 'apt list --upgradable' to see them.

cky@cky:~$ sudo apt -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

But it dosen't help much, the problem is still the same as before. The sources.list has been changed to a faster one, can that has something to do with the problem?

Here's the sources.list

cky@cky:~$ sudo cat /etc/apt/sources.list
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

## Not recommended
# deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
cky@cky:~$ sudo cat /etc/apt/sources.list.d/*
cat: '/etc/apt/sources.list.d/*': No such file or directory

It's too slow using the default source xD I'm trying other possible sources

19% [21 Packages 269 kB/1,019 kB 26%]                       15.3 kB/s 45min 35s
Zanna
  • 70,465
Duuang
  • 3
  • 3
    Looks like you are running 18.04, but the vim you are trying to install comes from the 16.04 repositories. Fix your /etc/apt/sources* - do not mix repositories from different releases of Ubuntu. If you don't know how to fix your sources, then please edit your question to include the complete output of cat /etc/apt/sources.list /etc/apt/sources.list.d/* – user535733 Oct 08 '18 at 10:53
  • 1
    @user535733 Wow..that is exactly the reason of the problem. The source was for ubuntu 16.04. The problem has been solved after changing the source to the one for 18.04. Thanks again, it really helps – Duuang Oct 08 '18 at 11:37

1 Answers1

1

Good on you for paying attention to the warning!

Your roommate is correct - there is something very wrong. This is how an aptitude install should look:

$ sudo apt install aptitude
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libssl-doc
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  aptitude-common libcwidget3v5
Suggested packages:
  aptitude-doc-en | aptitude-doc apt-xapian-index debtags tasksel
  libcwidget-dev
The following NEW packages will be installed:
  aptitude aptitude-common libcwidget3v5
0 to upgrade, 3 to newly install, 0 to remove and 0 not to upgrade.
Need to get 2,569 kB of archives.
After this operation, 10.9 MB of additional disk space will be used.
Do you want to continue? [Y/n]

First thing I notice is that you are trying to install libboost-iostreams1.58.0. I already have libboost-iostreams1.65.1 installed, so my guess is you haven't yet run apt-get update. Please do that first so you know you're getting an up-to-date reference of the repository and correct versions of all the software packages.

Then, from your earlier line:

E: Unable to correct problems, you have held broken packages.

I think you may have a package that has not completed its installation. Try running:

apt -f install

UPDATE

As @user535733 guessed, the OP's repositories were incorrect. Their repositories in /etc/apt/sources.d/ didn't match the version of Ubuntu they were running. This is unlikely to happen by mistake but could have happened as a result of an external script if it wasn't deliberate.

  • In 95% of these cases my problems are caused by forgetting apt-get update. It needs emphasis: always update your repos before install stuff. – aggregate1166877 May 01 '20 at 01:00