代码之家  ›  专栏  ›  技术社区  ›  vtable

无法在Ubuntu 20.04 WSL中安装GCC

  •  0
  • vtable  · 技术社区  · 3 年前

    我尝试在WSL上的Ubuntu 20.04中安装gcc:

    apt -y install gcc 返回错误:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    gcc is already the newest version (4:9.3.0-1ubuntu2).
    0 upgraded, 0 newly installed, 0 to remove and 194 not upgraded.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Setting up gcc (4:9.3.0-1ubuntu2) ...
    update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
    dpkg: error processing package gcc (--configure):
     installed gcc package post-installation script subprocess returned error exit status 2
    Errors were encountered while processing:
     gcc
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    我试着用以下方法修复它:

    sudo dpkg --purge --force-depends gcc 
    sudo apt-get autoremove -y
    sudo apt-get autoclean -y
    sudo apt-get clean gcc
    sudo apt-get install gcc
    

    但后来我发现了一个错误:

        root@LAP123:/home/my_user# sudo apt-get install gcc
       .......
    Setting up desktop-file-utils (0.24-1ubuntu3) ...
        /var/lib/dpkg/info/desktop-file-utils.postinst: 5: update-desktop-database: not found
        dpkg: error processing package desktop-file-utils (--configure):
         installed desktop-file-utils package post-installation script subprocess returned error exit status 127
        Setting up gcc (4:9.3.0-1ubuntu2) ...
        update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
        dpkg: error processing package gcc (--configure):
         installed gcc package post-installation script subprocess returned error exit status 2
        Processing triggers for man-db (2.9.1-1) ...
        Errors were encountered while processing:
         desktop-file-utils
         gcc
        E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    如何在Ubuntu中安装gcc?

    0 回复  |  直到 3 年前