解决重新安装 Firefox 时 dpkg 错误

解决重新安装 Firefox 时 dpkg 错误

我想删除 Firefox,因为我没有太多 Linux 经验。我想将 Chrome 设为我的默认浏览器,但它没有显示在“设置”中,所以我使用文件资源管理器“firefox”进行搜索并删除了所有内容。现在我想重新安装它,但它给了我这个错误消息:

$ sudo apt-get install firefox 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
firefox is already the newest version (61.0.1-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up firefox (61.0.1-1) ...
update-alternatives: error: alternative path /usr/bin/firefox doesn't exist
dpkg: error processing package firefox (--configure):
 installed firefox package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 firefox
Configuring sandbox profiles....
Sandbox profiles updated!
E: Sub-process /usr/bin/dpkg returned an error code (1)

apt-cache policy firefox输出

$apt-cache policy firefox firefox: Installed: 61.0.1-1 Candidate: 61.0.1-1 Version table: *** 61.0.1-1 1001 1001 http://deb.parrotsec.org/parrot stable/main amd64 Packages 100 /var/lib/dpkg/status

答案1

在您的桌面上(在)创建一个名为 firefox 的文件,~/Desktop并将以下文本复制到其中。

#!/bin/sh

set -e

# Firefox launcher containing a Profile migration helper for
# temporary profiles used during alpha and beta phases.

# Authors:
#  Alexander Sack <[email protected]>
#  Fabien Tassin <[email protected]>
#  Steve Langasek <[email protected]>
#  Chris Coulson <[email protected]>
# License: GPLv2 or later

MOZ_LIBDIR=/usr/lib/firefox
MOZ_APP_LAUNCHER=`which $0`
MOZ_APP_NAME=firefox

export MOZ_APP_LAUNCHER

while [ ! -x $MOZ_LIBDIR/$MOZ_APP_NAME ] ; do
    if [ -L "$MOZ_APP_LAUNCHER" ] ; then
        MOZ_APP_LAUNCHER=`readlink -f $MOZ_APP_LAUNCHER`
        MOZ_LIBDIR=`dirname $MOZ_APP_LAUNCHER`
    else
        echo "Can't find $MOZ_LIBDIR/$MOZ_APP_NAME"
        exit 1
    fi
done

usage () {
    $MOZ_LIBDIR/$MOZ_APP_NAME -h | sed -e 's,/.*/,,'
    echo
    echo "      -g or --debug          Start within debugger"
    echo "      -d or --debugger       Specify debugger to start with (eg, gdb or valgrind)"
    echo "      -a or --debugger-args  Specify arguments for debugger"
}

moz_debug=0
moz_debugger_args=""
moz_debugger="gdb"

while [ $# -gt 0 ]; do
    case "$1" in
        -h | --help )
            usage
            exit 0
            ;;
        -g | --debug )
            moz_debug=1
            shift
            ;;
        -d | --debugger)
            moz_debugger=$2;
            if [ "${moz_debugger}" != "" ]; then
          shift 2
            else
              echo "-d requires an argument"
              exit 1
            fi
            ;;
        -a | --debugger-args )
            moz_debugger_args=$2;
            if [ "${moz_debugger_args}" != "" ] ; then
                shift 2
            else
                echo "-a requires an argument"
                exit 1
            fi
            ;;
        -- ) # Stop option processing
            shift
            break
            ;;
        * )
            break
            ;;
    esac
done

if [ $moz_debug -eq 1 ] ; then
    case $moz_debugger in
        memcheck)
            debugger="valgrind"
            ;;
        *)
            debugger=$moz_debugger
            ;;
    esac

    debugger=`which $debugger`
    if [ ! -x $debugger ] ; then
        echo "Invalid debugger"
        exit 1
    fi

    case `basename $moz_debugger` in
        gdb)
            exec $debugger $moz_debugger_args --args $MOZ_LIBDIR/$MOZ_APP_NAME "$@"
            ;;
        memcheck)
            echo "$MOZ_APP_NAME has not been compiled with valgrind support"
            exit 1
            ;;
        *)
            exec $debugger $moz_debugger_args $MOZ_LIBDIR/$MOZ_APP_NAME "$@"
            ;;
    esac
else
    exec $MOZ_LIBDIR/$MOZ_APP_NAME "$@"
fi

打开终端并输入:

sudo cp ~/Desktop/firefox /usr/bin/

结果apt-cache policy firefox显示 Firefox 仍然安装。删除 Firefox 安装的所有内容并重新安装 Firefox。

sudo dpkg --remove --force-remove-reinstreq firefox # remove existing firefox package   
sudo apt install firefox  

相关内容