You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

误删GUI后安装ubuntu-desktop遇依赖冲突,请求分步修复方案

误删GUI后安装ubuntu-desktop遇依赖冲突,请求分步修复方案

Hey Arash, sorry to hear you're stuck with this messy dependency issue after removing your GUI. Let's work through this step by step to get your Ubuntu desktop back up and running smoothly.

First, here's the error you encountered when running sudo apt install ubuntu-desktop:

Reading package lists... Done
Building dependency tree... Done
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:
 gdm3 : Depends: gnome-shell (>= 3.19.92) but it is not installable
 gir1.2-snapd-1 : Depends: libsnapd-glib1 (= 1.58-0ubuntu0.20.04.0) but 1.60-0ubuntu1 is to be installed
 gjs : Depends: libgjs0g (>= 1.63.90) but it is not installable
 gnome-session-bin : Depends: dbus-x11
 gnome-settings-daemon : Depends: gnome-settings-daemon-common (= 3.36.1-0ubuntu1.1) but 42.1-1ubuntu2.2 is to be installed
 gnome-shell-extension-appindicator : Depends: gnome-shell (>= 3.33) but it is not installable
 Depends: gnome-shell (< 3.37) but it is not installable
 gnome-shell-extension-desktop-icons : Depends: gnome-shell (>= 3.33) but it is not installable
 gnome-shell-extension-ubuntu-dock : Depends: gnome-shell (< 3.37) but it is not installable
 Depends: gnome-shell (>= 3.35.90) but it is not installable
 language-selector-gnome : Depends: language-selector-common (= 0.204.2) but 0.219.1 is to be installed
 libcairo-gobject-perl : Depends: perlapi-5.30.0
 Depends: libcairo-perl but it is not going to be installed
 libglib-perl : Depends: perlapi-5.30.0
 libgtk3-perl : Depends: libglib-object-introspection-perl (>= 0.043) but it is not installable
 libpulse-mainloop-glib0 : Depends: libpulse0 (= 1:13.99.1-1ubuntu3.13) but 1:15.99.1+dfsg1-1ubuntu2.1 is to be installed
 libsmbclient : Depends: samba-libs (= 2:4.15.13+dfsg-0ubuntu0.20.04.7) but 2:4.15.13+dfsg-0ubuntu1.5 is to be installed
 Depends: libwbclient0 (= 2:4.15.13+dfsg-0ubuntu0.20.04.7) but 2:4.15.13+dfsg-0ubuntu1.5 is to be installed
 software-properties-gtk : Depends: python3-software-properties (= 0.99.9.12) but 0.99.22.8 is to be installed
 Recommends: gnome-keyring but it is not installable
 ubuntu-desktop : Depends: gnome-shell but it is not installable
 Recommends: deja-dup but it is not installable
 Recommends: gnome-calendar but it is not installable
 Recommends: gnome-keyring but it is not installable
 Recommends: gnome-todo but it is not installable
 Recommends: libreoffice-style-breeze but it is not going to be installed
 Recommends: network-manager-pptp-gnome but it is not installable
 Recommends: orca but it is not installable
 Recommends: seahorse but it is not installable
 Recommends: shotwell but it is not installable
 ubuntu-desktop-minimal : Depends: gnome-shell but it is not installable
 Recommends: gnome-keyring but it is not installable
 Recommends: network-manager-pptp-gnome but it is not installable
 Recommends: orca but it is not installable
 Recommends: seahorse but it is not installable
 ubuntu-session : Depends: gnome-shell (>= 3.36.0-2ubuntu1*) but it is not installable
E: Unable to correct problems, you have held broken packages

Now let's fix this step by step:

  • Step 1: Check for held packages
    The error mentions "you have held broken packages" — these are packages locked to a specific version that can't be updated or removed, which is likely causing the conflicts. Let's find them first:

    dpkg --get-selections | grep hold
    

    If any packages show up, unlock each one with:

    sudo apt-mark unhold <package-name>
    

    Replace <package-name> with each held package you found, and repeat for all of them.

  • Step 2: Clean and update your package sources
    Old cached packages and outdated source lists often cause dependency mismatches. Run these commands to refresh everything:

    sudo apt clean
    sudo apt update --fix-missing
    
    • apt clean clears out old downloaded package files
    • update --fix-missing refreshes your repository lists and fixes any missing source information
  • Step 3: Attempt automatic dependency repair
    Ubuntu's package manager has a built-in tool to fix broken dependencies. Run this:

    sudo apt -f install
    

    This command will try to install missing dependencies or remove conflicting packages to resolve issues. Follow any prompts (usually just press Y to confirm changes).

  • Step 4: Use aptitude for advanced dependency resolution
    If apt -f install doesn't work, try aptitude — it's better at handling complex conflicts and will offer multiple solutions. First install it if you don't have it:

    sudo apt install aptitude
    

    Then try installing ubuntu-desktop with aptitude:

    sudo aptitude install ubuntu-desktop
    

    When presented with options, read carefully. Usually option 2 (which suggests downgrading conflicting packages) is the right choice. Type the option number and press Enter, then confirm the changes.

  • Step 5: Reconfigure all installed packages
    If some packages were left half-configured, this command will fix that:

    sudo dpkg --configure -a
    

    This goes through all installed packages to ensure they're properly set up.

  • Step 6: Try installing ubuntu-desktop again
    Once you've completed the above steps, run the original installation command again:

    sudo apt install ubuntu-desktop
    

    This should now install without dependency errors.

If you still run into issues after these steps, let me know and we can troubleshoot further!

备注:内容来源于stack exchange,提问作者Arash Jadid

火山引擎 最新活动