PagalSarthak / Remove-snap-in-ubuntu

GNU General Public License v3.0
12 stars 1 forks source link

Error: Failed to remove snap package: core22 #1

Closed rafisics closed 1 month ago

rafisics commented 1 month ago

In Ubuntu 24.04 LTS, I am getting this error:

$ ./remove_snap.sh 
  https://github.com/PagalSarthak/Remove-snap-in-ubuntu
  thx for using our script
  This script will remove Snap packages and the Snapd service and install Firefox for you. Do you want to continue? [y/n]: y
  Removing snap packages...
  [sudo] password for rafi: 
  snap "firefox" is not installed
  gtk-common-themes removed
  gnome-42-2204 removed
  snapd-desktop-integration removed
  snap-store removed
  snap "firmware-updater" is not installed
  bare removed
  error: cannot remove "core22": snap "core22" is not removable:
         snap is being used by snaps canonical-livepatch, cups,
         kf5-5-106-qt-5-15-9-core22, kf5-5-108-qt-5-15-10-core22 and
         kf5-5-110-qt-5-15-11-core22.
  Error: Failed to remove snap package: core22
$ snap list
Name                         Version                     Rev    Tracking       Publisher      Notes
canonical-livepatch          10.8.3                      282    latest/stable  canonical✓     -
core                         16-2.61.4-20240607          17200  latest/stable  canonical✓     core
core18                       20240612                    2829   latest/stable  canonical✓     base
core20                       20240416                    2318   latest/stable  canonical✓     base
core22                       20240823                    1612   latest/stable  canonical✓     base
cups                         2.4.10-1                    1058   latest/stable  openprinting✓  -
curl                         8.1.2                       1754   latest/stable  woutervb       -
gnome-3-28-1804              3.28.0-19-g98f9e67.98f9e67  198    latest/stable  canonical✓     -
kf5-5-106-qt-5-15-9-core22   5.106                       23     latest/stable  kde✓           -
kf5-5-108-qt-5-15-10-core22  5.108                       5      latest/stable  kde✓           -
kf5-5-110-qt-5-15-11-core22  5.110                       3      latest/stable  kde✓           -
snapd                        2.63                        21759  latest/stable  canonical✓     snapd
PagalSarthak commented 1 month ago

thx for your feedback the issue is core22 using kf5-5-110-qt-5-15-11-core22 or cups cups is ur printer driver

sudo snap remove kf5-5-106-qt-5-15-9-core22
sudo snap remove kf5-5-108-qt-5-15-10-core22
sudo snap remove kf5-5-110-qt-5-15-11-core22
sudo snap remove cups
sudo snap remove curl
sudo snap remove core20
sudo snap remove core18
sudo snap remove gnome-3-28-1804

or i will make new script for you ? u need to replace cups to deb package

rafisics commented 1 month ago

Thanks for replying. Yeah, I was thinking of removing them with sudo snap remove, but would I need to install any essential alternative after removing them? It would be great if you could configure the script considering these.

PagalSarthak commented 1 month ago

yes you do ok i will make a script today that meets your requirement

rafisics commented 1 month ago

Thanks, I would be waiting.

PagalSarthak commented 1 month ago

ok i make the script for u but first i want to verify that r u using KDE ?? or KDE software

rafisics commented 1 month ago

I am not very aware this thing, but I found this:

$ dpkg -l | grep -i kde
ii  kaccounts-providers                            4:23.08.5-0ubuntu3                                   amd64        KDE providers for accounts sign-on
rc  kdeconnect                                     21.12.3-0ubuntu1                                     amd64        connect smartphones to your desktop devices
ii  kded5                                          5.115.0-0ubuntu5                                     amd64        Extensible daemon for providing session services
ii  keditbookmarks                                 23.08.5-0ubuntu4                                     amd64        bookmarks editor utility for KDE
ii  kinit                                          5.115.0-0ubuntu6                                     amd64        process launcher to speed up launching KDE applications
ii  libblockdev-crypto3:amd64                      3.1.1-1                                              amd64        Crypto plugin for libblockdev
ii  libblockdev-fs3:amd64                          3.1.1-1                                              amd64        file system plugin for libblockdev
ii  libblockdev-loop3:amd64                        3.1.1-1                                              amd64        Loop device plugin for libblockdev
ii  libblockdev-mdraid3:amd64                      3.1.1-1                                              amd64        MD RAID plugin for libblockdev
ii  libblockdev-nvme3:amd64                        3.1.1-1                                              amd64        NVMe plugin for libblockdev
ii  libblockdev-part3:amd64                        3.1.1-1                                              amd64        Partitioning plugin for libblockdev
ii  libblockdev-swap3:amd64                        3.1.1-1                                              amd64        Swap plugin for libblockdev
ii  libblockdev-utils3:amd64                       3.1.1-1                                              amd64        Utility functions for libblockdev
ii  libblockdev3:amd64                             3.1.1-1                                              amd64        Library for manipulating block devices
ii  libkf5calendarevents5:amd64                    5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE frameworks -- calendarevents
ii  libkf5coreaddons-data                          5.115.0-0ubuntu5                                     all          KDE Frameworks 5 addons to QtCore - data files
ii  libkf5coreaddons5:amd64                        5.115.0-0ubuntu5                                     amd64        KDE Frameworks 5 addons to QtCore
ii  libkf5declarative-data                         5.115.0-0ubuntu5                                     all          provides integration of QML and KDE frameworks
ii  libkf5declarative5:amd64                       5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE frameworks
ii  libkf5quickaddons5:amd64                       5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE frameworks -- quickaddons
ii  libphonon-l10n                                 4:4.12.0-3.1build3                                   all          multimedia framework from KDE using Qt - localization files
ii  libphonon4qt5-4t64:amd64                       4:4.12.0-3.1build3                                   amd64        multimedia framework from KDE using Qt 5 - core library
ii  phonon4qt5:amd64                               4:4.12.0-3.1build3                                   amd64        multimedia framework from KDE using Qt 5 - metapackage
ii  qml-module-org-kde-bluezqt:amd64               5.115.0-0ubuntu6                                     amd64        QML wrapper for bluez
ii  qml-module-org-kde-kconfig:amd64               5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE Frameworks - kconfig
ii  qml-module-org-kde-kirigami2                   5.115.0-0ubuntu6                                     amd64        set of QtQuick components targeted for mobile use
ii  qml-module-org-kde-kquickcontrols:amd64        5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE frameworks - kquickcontrols
ii  qml-module-org-kde-kquickcontrolsaddons:amd64  5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE Frameworks - kquickcontrolsaddons
ii  qml-module-org-kde-prison:amd64                5.115.0-0ubuntu5                                     amd64        barcode API for Qt
ii  qml-module-org-kde-purpose:amd64               5.115.0-0ubuntu4                                     amd64        abstraction to provide and leverage actions of a specific kind, qml bindings
PagalSarthak commented 1 month ago

u r are using KDE plasma or kubuntu and removing the kf5 Snap packages you mentioned could potentially lead to issues it might breaks thing too sorry for wasting ur time

rafisics commented 1 month ago

I am using Ubuntu 24.04 LTS, and I consciously use Gnome things.

echo $XDG_CURRENT_DESKTOP

ubuntu:GNOME

But I am not sure why I have those KDE things. Can it happen that I maybe tried testing with KDE tools and their traces are there?
No, you are not wasting my time. Can you suggest how I should verify in detail and what is safe to remove?

PagalSarthak commented 1 month ago

i think u try to install KDE in past i recommend not to remove KF5 buz u have app like KDE connect there is a some package u can remove and re install via repo

sudo snap remove cups
sudo snap remove curl
sudo snap remove gnome-3-28-1804

re install it via repo

sudo apt install cups 
sudo apt install curl

keep snaps and replace these packages

rafisics commented 1 month ago

I don't have KDE Connect installed, I use GSconnect now. Snaps are making the booting process slower.

PagalSarthak commented 1 month ago

if you don't use any of these then i make script for u that work fine see removing KF5 = u can't use any of these package still want to continue

kaccounts-providers   
kdeconnect 
kded5  
 qml-module-org-kde-bluezqt:amd64               5.115.0-0ubuntu6                                     amd64        QML wrapper for bluez
ii  qml-module-org-kde-kconfig:amd64               5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE Frameworks - kconfig
ii  qml-module-org-kde-kirigami2                   5.115.0-0ubuntu6                                     amd64        set of QtQuick components targeted for mobile use
ii  qml-module-org-kde-kquickcontrols:amd64        5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE frameworks - kquickcontrols
ii  qml-module-org-kde-kquickcontrolsaddons:amd64  5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE Frameworks - kquickcontrolsaddons
ii  qml-module-org-kde-prison:amd64                5.115.0-0ubuntu5                                     amd64        barcode API for Qt
ii  qml-module-org-kde-purpose:amd64               5.115.0-0ubuntu4                                     amd64        abstraction to provide and leverage actions of a specific kind, qml bindings
rafisics commented 1 month ago

As I told you, the issue is I am not sure where these KDE are used in my system. Are they standalone applications or are they installed due to the dependency on other applications? Can you suggest any way to check and verify their use and dependency?

PagalSarthak commented 1 month ago

these KDE installed due to dependency of

kaccounts-providers   
kdeconnect 
kded5  

can u show me the result of dpkg -l | grep libkf

rafisics commented 1 month ago
$ dpkg -l | grep libkf
ii  libkf5activities5:amd64                        5.115.0-0ubuntu3                                     amd64        Library to organize the user work in separate activities.
ii  libkf5archive-data                             5.115.0-0ubuntu5                                     all          data files for karchive
ii  libkf5archive5:amd64                           5.115.0-0ubuntu5                                     amd64        Qt 5 addon providing access to numerous types of archives
ii  libkf5auth-data                                5.115.0-0ubuntu5                                     all          Abstraction to system policy and authentication features
ii  libkf5authcore5:amd64                          5.115.0-0ubuntu5                                     amd64        Abstraction to system policy and authentication features
ii  libkf5bluezqt-data                             5.115.0-0ubuntu6                                     all          data files for bluez-qt
ii  libkf5bluezqt6:amd64                           5.115.0-0ubuntu6                                     amd64        Qt wrapper for bluez
ii  libkf5bookmarks-data                           5.115.0-0ubuntu5                                     all          Qt library with support for bookmarks and the XBEL format.
ii  libkf5bookmarks5:amd64                         5.115.0-0ubuntu5                                     amd64        Qt library with support for bookmarks and the XBEL format.
ii  libkf5calendarevents5:amd64                    5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE frameworks -- calendarevents
ii  libkf5codecs-data                              5.115.0-0ubuntu5                                     all          collection of methods to manipulate strings
ii  libkf5codecs5:amd64                            5.115.0-0ubuntu5                                     amd64        collection of methods to manipulate strings
ii  libkf5completion-data                          5.115.0-0ubuntu5                                     all          Widgets with advanced auto-completion features.
ii  libkf5completion5:amd64                        5.115.0-0ubuntu5                                     amd64        Widgets with advanced auto-completion features.
ii  libkf5config-bin                               5.115.0-0ubuntu5                                     amd64        configuration settings framework for Qt
ii  libkf5config-data                              5.115.0-0ubuntu5                                     all          configuration settings framework for Qt
ii  libkf5configcore5:amd64                        5.115.0-0ubuntu5                                     amd64        configuration settings framework for Qt
ii  libkf5configgui5:amd64                         5.115.0-0ubuntu5                                     amd64        configuration settings framework for Qt
ii  libkf5configwidgets-data                       5.115.0-0ubuntu5                                     all          Extra widgets for easier configuration support.
ii  libkf5configwidgets5:amd64                     5.115.0-0ubuntu5                                     amd64        Extra widgets for easier configuration support.
rc  libkf5contacts-data                            5:5.92.0-0ubuntu1                                    all          data files for kcontacts
ii  libkf5coreaddons-data                          5.115.0-0ubuntu5                                     all          KDE Frameworks 5 addons to QtCore - data files
ii  libkf5coreaddons5:amd64                        5.115.0-0ubuntu5                                     amd64        KDE Frameworks 5 addons to QtCore
ii  libkf5crash5:amd64                             5.115.0-0ubuntu5                                     amd64        Support for application crash analysis and bug report from apps
ii  libkf5dbusaddons-bin                           5.115.0-0ubuntu5                                     amd64        class library for qtdbus
ii  libkf5dbusaddons-data                          5.115.0-0ubuntu5                                     all          class library for qtdbus
ii  libkf5dbusaddons5:amd64                        5.115.0-0ubuntu5                                     amd64        class library for qtdbus
ii  libkf5declarative-data                         5.115.0-0ubuntu5                                     all          provides integration of QML and KDE frameworks
ii  libkf5declarative5:amd64                       5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE frameworks
ii  libkf5doctools5:amd64                          5.115.0-0ubuntu5                                     amd64        Tools to generate documentation in various formats from DocBook
ii  libkf5globalaccel-bin                          5.115.0-0ubuntu5                                     amd64        Configurable global shortcut support.
ii  libkf5globalaccel-data                         5.115.0-0ubuntu5                                     all          Configurable global shortcut support.
ii  libkf5globalaccel5:amd64                       5.115.0-0ubuntu5                                     amd64        Configurable global shortcut support.
ii  libkf5globalaccelprivate5:amd64                5.115.0-0ubuntu5                                     amd64        Configurable global shortcut support - private runtime library
ii  libkf5guiaddons-bin                            5.115.0-0ubuntu5                                     amd64        additional addons for QtGui (runtime)
ii  libkf5guiaddons-data                           5.115.0-0ubuntu5                                     all          additional addons for QtGui (documentation)
ii  libkf5guiaddons5:amd64                         5.115.0-0ubuntu5                                     amd64        additional addons for QtGui
ii  libkf5i18n-data                                5.115.0-0ubuntu6                                     all          Advanced internationalization framework.
ii  libkf5i18n5:amd64                              5.115.0-0ubuntu6                                     amd64        Advanced internationalization framework.
ii  libkf5iconthemes-bin                           5.115.0-0ubuntu6                                     amd64        Support for icon themes
ii  libkf5iconthemes-data                          5.115.0-0ubuntu6                                     all          Support for icon themes.
ii  libkf5iconthemes5:amd64                        5.115.0-0ubuntu6                                     amd64        Support for icon themes.
ii  libkf5itemviews-data                           5.115.0-0ubuntu5                                     all          Qt library with additional widgets for ItemModels
ii  libkf5itemviews5:amd64                         5.115.0-0ubuntu5                                     amd64        Qt library with additional widgets for ItemModels
ii  libkf5jobwidgets-data                          5.115.0-0ubuntu5                                     all          Widgets for tracking KJob instances
ii  libkf5jobwidgets5:amd64                        5.115.0-0ubuntu5                                     amd64        Widgets for tracking KJob instances
ii  libkf5js5t64:amd64                             5.115.0-0ubuntu8                                     amd64        Support for JS scripting in Qt applications
ii  libkf5kdcraw5:amd64                            23.08.5-0ubuntu3                                     amd64        RAW picture decoding library
ii  libkf5kexiv2-15.0.0:amd64                      23.08.5-0ubuntu3                                     amd64        Qt like interface for the libexiv2 library
ii  libkf5khtml-bin                                5.115.0-0ubuntu7                                     amd64        HTML widget and component
ii  libkf5khtml-data                               5.115.0-0ubuntu7                                     all          HTML widget and component
ii  libkf5khtml5:amd64                             5.115.0-0ubuntu7                                     amd64        HTML widget and component
ii  libkf5kiocore5:amd64                           5.115.0-0ubuntu6                                     amd64        resource and network access abstraction (KIO core library)
ii  libkf5kiogui5:amd64                            5.115.0-0ubuntu6                                     amd64        resource and network access abstraction (KIO gui library)
ii  libkf5kiontlm5:amd64                           5.115.0-0ubuntu6                                     amd64        resource and network access abstraction (KIO NTLM library)
ii  libkf5kiowidgets5:amd64                        5.115.0-0ubuntu6                                     amd64        resource and network access abstraction (KIO widgets library)
ii  libkf5kirigami2-5                              5.115.0-0ubuntu6                                     amd64        set of QtQuick components targeted for mobile use
ii  libkf5notifications-data                       5.115.0-0ubuntu6                                     all          Framework for desktop notifications
ii  libkf5notifications5:amd64                     5.115.0-0ubuntu6                                     amd64        Framework for desktop notifications
ii  libkf5package-data                             5.115.0-0ubuntu5                                     all          non-binary asset management framework
ii  libkf5package5:amd64                           5.115.0-0ubuntu5                                     amd64        non-binary asset management framework
ii  libkf5parts-data                               5.115.0-0ubuntu5                                     all          Document centric plugin system.
ii  libkf5parts-plugins:amd64                      5.115.0-0ubuntu5                                     amd64        Document centric plugin system.
ii  libkf5parts5:amd64                             5.115.0-0ubuntu5                                     amd64        Document centric plugin system.
rc  libkf5people5:amd64                            5.92.0-0ubuntu1                                      amd64        framework providing unified access to contacts aggregated by person
ii  libkf5plasma5:amd64                            5.115.0-0ubuntu4                                     amd64        Plasma Runtime components
ii  libkf5plasmaquick5:amd64                       5.115.0-0ubuntu4                                     amd64        Plasma Runtime components
ii  libkf5prison5:amd64                            5.115.0-0ubuntu5                                     amd64        barcode API for Qt
ii  libkf5pty-data                                 5.115.0-0ubuntu4                                     all          Pty abstraction.
ii  libkf5pty5:amd64                               5.115.0-0ubuntu4                                     amd64        Pty abstraction.
ii  libkf5purpose-bin:amd64                        5.115.0-0ubuntu4                                     amd64        abstraction to provide and leverage actions of a specific kind, runtime
ii  libkf5purpose5:amd64                           5.115.0-0ubuntu4                                     amd64        library for abstractions to get the developer's purposes fulfilled
ii  libkf5quickaddons5:amd64                       5.115.0-0ubuntu5                                     amd64        provides integration of QML and KDE frameworks -- quickaddons
ii  libkf5service-bin                              5.115.0-0ubuntu4                                     amd64        Advanced plugin and service introspection
ii  libkf5service-data                             5.115.0-0ubuntu4                                     all          Advanced plugin and service introspection
ii  libkf5service5:amd64                           5.115.0-0ubuntu4                                     amd64        Advanced plugin and service introspection
ii  libkf5solid5:amd64                             5.115.0-0ubuntu5                                     amd64        Qt library to query and control hardware
ii  libkf5solid5-data                              5.115.0-0ubuntu5                                     all          Qt library to query and control hardware
ii  libkf5sonnet5-data                             5.115.0-0ubuntu5                                     all          spell checking library for Qt, data files
ii  libkf5sonnetcore5:amd64                        5.115.0-0ubuntu5                                     amd64        spell checking library for Qt, core lib
ii  libkf5sonnetui5:amd64                          5.115.0-0ubuntu5                                     amd64        spell checking library for Qt, ui lib
ii  libkf5textwidgets-data                         5.115.0-0ubuntu4                                     all          Advanced text editing widgets.
ii  libkf5textwidgets5:amd64                       5.115.0-0ubuntu4                                     amd64        Advanced text editing widgets.
ii  libkf5threadweaver5:amd64                      5.115.0-0ubuntu4                                     amd64        ThreadWeaver library to help multithreaded programming in Qt
ii  libkf5wallet-bin                               5.115.0-0ubuntu3                                     amd64        Secure and unified container for user passwords.
ii  libkf5wallet-data                              5.115.0-0ubuntu3                                     all          Secure and unified container for user passwords.
ii  libkf5wallet5:amd64                            5.115.0-0ubuntu3                                     amd64        Secure and unified container for user passwords.
ii  libkf5waylandclient5:amd64                     4:5.115.0-0ubuntu5                                   amd64        Qt library wrapper for Wayland libraries
ii  libkf5widgetsaddons-data                       5.115.0-0ubuntu4                                     all          add-on widgets and classes for applications that use the Qt Widgets module
ii  libkf5widgetsaddons5:amd64                     5.115.0-0ubuntu4                                     amd64        add-on widgets and classes for applications that use the Qt Widgets module
ii  libkf5windowsystem-data                        5.115.0-0ubuntu4                                     all          Convenience access to certain properties and features of the window manager
ii  libkf5windowsystem5:amd64                      5.115.0-0ubuntu4                                     amd64        Convenience access to certain properties and features of the window manager
ii  libkf5xmlgui-bin:amd64                         5.115.0-0ubuntu5                                     amd64        User configurable main windows.
ii  libkf5xmlgui-data                              5.115.0-0ubuntu5                                     all          User configurable main windows.
ii  libkf5xmlgui5:amd64                            5.115.0-0ubuntu5                                     amd64        User configurable main windows.
rafisics commented 1 month ago

I am using the Gnome desktop environment, so are kaccounts-providers, kdeconnect, kded5 necessary? Maybe not, right?

rafisics commented 1 month ago
$ apt-cache rdepends kaccounts-providers
kaccounts-providers
Reverse Depends:
  libkaccounts2
  plasma-settings
  libkaccounts2
  kaccounts-integration
  kubuntu-desktop
$ apt-cache rdepends kdeconnect
kdeconnect
Reverse Depends:
  nautilus-kdeconnect
  ubuntustudio-desktop
  qml-module-org-kde-purpose
  nautilus-kdeconnect
  kde-plasma-desktop
  nautilus-kdeconnect
  libkf5purpose-bin
  kubuntu-desktop
 apt-cache rdepends kded5
kded5
Reverse Depends:
  libkf5coreaddons5
  plasma-workspace
  plasma-workspace
  plasma-desktop
  libkf5dbusaddons5
  libkf5crash5
  kded5-dev
  kio
  kdenlive
PagalSarthak commented 1 month ago

If you're using GNOME and want to remove KDE-related packages to streamline your system, you can follow these steps. Keep in mind that removing KDE libraries and applications may affect any KDE applications you have installed or any features that rely on KDE components. sudo apt remove --purge kdeconnect keditbookmarks kaccounts-providers kded5

sudo apt remove --purge kubuntu-desktop kde-plasma-desktop plasma-desktop

sudo apt autoremove --purge
sudo apt clean
rafisics commented 1 month ago

Thanks. I followed those commands. Now, the snap list shows:

Name                         Version             Rev    Tracking       Publisher   Notes
canonical-livepatch          10.8.3              282    latest/stable  canonical✓  -
core                         16-2.61.4-20240607  17200  latest/stable  canonical✓  core
core18                       20240612            2829   latest/stable  canonical✓  base
core20                       20240416            2318   latest/stable  canonical✓  base
core22                       20240823            1612   latest/stable  canonical✓  base
kf5-5-106-qt-5-15-9-core22   5.106               23     latest/stable  kde✓        -
kf5-5-108-qt-5-15-10-core22  5.108               5      latest/stable  kde✓        -
kf5-5-110-qt-5-15-11-core22  5.110               3      latest/stable  kde✓        -
snapd                        2.63                21759  latest/stable  canonical✓  snapd
PagalSarthak commented 1 month ago

make a .sh file and past this code in it and chmod +x<name>.sh ./<name>.sh

#!/bin/bash
echo "https://github.com/PagalSarthak/Remove-snap-in-ubuntu"
echo "thx for using our script"

set -e

# Function to prompt for user confirmation
prompt_confirmation() {
    while true; do
        read -p "$1 [y/n]: " choice
        case "$choice" in
            y|Y ) return 0;; # Yes
            n|N ) echo "Operation aborted."; exit 1;; # No
            * ) echo "Please answer yes or no.";;
        esac
    done
}

# Function to remove all Snap packages
remove_snap_packages() {
    echo "Removing all Snap packages..."
    # Get a list of all installed snap packages
    local packages
    packages=$(snap list | awk 'NR > 1 {print $1}')

    # Loop through the list and remove each package
    for snap_package in $packages; do
        echo "Removing $snap_package..."
        sudo snap remove "$snap_package" || true
        sleep 2  # Adding a short delay to ensure the package is removed
    done
}

# Function to remove Snapd service
remove_snapd() {
    echo "Stopping and disabling snapd service..."
    sudo systemctl stop snapd || true
    sudo systemctl disable snapd || true
    sudo systemctl mask snapd || true

    echo "Removing Snapd service..."
    sudo apt-get purge -y snapd || true
}

# Function to clean up residual Snap directories
cleanup() {
    echo "Cleaning up leftover Snap directories..."
    sudo rm -rf /var/cache/snapd/
    sudo rm -rf /var/snap/
    sudo rm -rf /snap/
    sudo rm -rf /var/lib/snapd/
}

# Function to create a preference file to prevent Snap from being reinstalled
create_preference_file() {
    echo "Creating preference file to prevent Snap from being reinstalled..."
    echo "Package: snapd" | sudo tee /etc/apt/preferences.d/nosnap.pref > /dev/null
    echo "Pin: release a=*" | sudo tee -a /etc/apt/preferences.d/nosnap.pref > /dev/null
    echo "Pin-Priority: -10" | sudo tee -a /etc/apt/preferences.d/nosnap.pref > /dev/null
}

# Function to install Firefox from Mozilla's repository
install_firefox() {
    echo "Adding Mozilla's APT repository and installing Firefox..."
    sudo install -d -m 0755 /etc/apt/keyrings || handle_error "Failed to create keyrings directory"
    wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null || handle_error "Failed to download Mozilla signing key"
    echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee /etc/apt/sources.list.d/mozilla.list > /dev/null || handle_error "Failed to add Mozilla APT repository"
    echo "Package: *" | sudo tee /etc/apt/preferences.d/mozilla > /dev/null
    echo "Pin: origin packages.mozilla.org" | sudo tee -a /etc/apt/preferences.d/mozilla > /dev/null
    echo "Pin-Priority: 1000" | sudo tee -a /etc/apt/preferences.d/mozilla > /dev/null
    sudo apt-get update && sudo apt-get install -y firefox || handle_error "Failed to install Firefox"
}

# Function to install GNOME Software
install_gnome_software() {
    echo "Installing GNOME Software..."
    sudo apt install -y gnome-software || handle_error "Failed to install GNOME Software"
}

# Function to handle errors
handle_error() {
    echo "Error: $1"
    exit 1
}

# Main script execution
echo "Starting Snap removal process..."

# First, remove snapd if it's installed
remove_snapd

# Remove all Snap packages
while snap list | awk 'NR > 1 {print $1}' | grep .; do
    remove_snap_packages
    echo "Waiting for Snap packages to be fully removed..."
    sleep 5
done

# Clean up Snap directories and create a preference file
cleanup
create_preference_file

# Prompt for confirmation to install Firefox
prompt_confirmation "Do you want to add Mozilla's APT repository and install Firefox?"

install_firefox

# Prompt for confirmation to install GNOME Software
prompt_confirmation "Do you want to install GNOME Software?"

install_gnome_software

echo "Snap removal process completed. Firefox and GNOME Software have been installed."
rafisics commented 1 month ago

I used this script. At the beginning it showed:

Stopping 'snapd.service', but its triggering units are still active:
snapd.socket
Removed "/etc/systemd/system/multi-user.target.wants/snapd.service".
Disabling 'snapd.service', but its triggering units are still active:
snapd.socket
Created symlink /etc/systemd/system/snapd.service → /dev/null.
Masking 'snapd.service', but its triggering units are still active:
snapd.socket
Removing Snapd service...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  snapd*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.

Is it an issue that it says but its triggering units are still active?

PagalSarthak commented 1 month ago

na its not try snap --version or snapd --version

rafisics commented 1 month ago

Yeah, they are not installed. Thank you so much for your time.

PagalSarthak commented 1 month ago

thx now i am closing this issue alright