JustinTimperio / pacback

Advanced Version Control for Arch Linux
MIT License
148 stars 4 forks source link

Pacback Already Has An Active Session Running. #30

Closed CyCodeDE closed 4 years ago

CyCodeDE commented 4 years ago

Description I already saw that other Issue that had the same problem, but the answers did not help. Running

sudo rm /tmp/pacback_session.lck

does not help, because the file does not exist. I tried killing the process with htop but it also does not seem to exist. Rebooting did not help either. The issue happens with the normal pacback version and with the pacback-git version. My home directory is on the standard /home path.

It just says: Critical Error! Pacback Already Has An Active Session Running.

My machine

To Reproduce Steps to reproduce the behavior:

  1. Run: sudo pacback -nc -f -c 1 -l 'Stable'

Expected behavior It should create a Restore Point

Please help me. Thank you.

JustinTimperio commented 4 years ago

@CyCodeDE

The reason sudo rm /tmp/pacback_session.lck does not work is that is has been completely removed in version 2.0.2. Pacback now uses fcntl to create open file locks. Once pacback's runtime concludes, the file is closed regards of a crash or a safe session close. Also pacback no longer uses hardcoded user home paths so that shouldn't be an issue either.

29 Has been successfully fixed so this is most likely an edge case error.

Can you please send me the output of ls /var/lib/pacback? If pacback_session.lck exists in this directory try removing it, although this should make no difference in theory.

mirh commented 4 years ago

I had the same problem (yes, with 2.0.2) Then I downgraded to 2.0.1 (removed the hook, because that's what I wanted to do.. idk if it matters), reinstalled 2.0.2 and it was working as expected.

JustinTimperio commented 4 years ago

Bizzare, I wonder if this has to do with some issue with the build package itself. (The hook is overwritten on each install so it shouldn't make a difference.)

@mirh So when you say 'working as expected' can I take it 2.0.2 is now working properly for you? I've tested the upgrade process on my test vms and it seemed to work fine.

JustinTimperio commented 4 years ago

I have tried to recreate this issue across multiple vm's doing both upgrades and downgrades without being able to get this behavior to manifest.

Please try the following as a last-ditch effort if this continues.

  1. sudo pacman -R pacback Will remove pacback and wipe all restore points, snapshots, configs, and application files.
  2. yay -S pacback Will perform a fresh install. (Or substitute your AUR Manager of choice)

If the behavior continues, I will need to do some serious bug testing as this is being caused by something not obvious/easily fixable.

CyCodeDE commented 4 years ago

Reinstalling did not help. And the pacback directory does not even exist in /var/lib

mirh commented 4 years ago

So when you say 'working as expected' can I take it 2.0.2 is now working properly for you?

Yes. I wasn't upgrading though. It was on a fresh VM (with an empty /home partition, and no sudoers, intriguingly)

JustinTimperio commented 4 years ago

Yeah, so this officially a bug then.

@mirh With the new version of pacback that shouldn't even matter because normal user paths are pulled out of /etc/passwd. If there aren't any normal users defined then it just skips looking in those directories. Even if you set your home path to /random/path/ it would pick it up fine.

@CyCodeDE So I apologize for this but I will probably need to ping you with some questions as I try and figure out why/how this is even happening.

Can you type this in your terminal then copy and paste the exact output for me to see? yay -S pacback && pacback -ls && sudo pacback -c 1

CyCodeDE commented 4 years ago

This is the exact output:

` ❯ yay -S pacback && pacback -ls && sudo pacback -c 1 :: Checking for conflicts... :: Checking for inner conflicts... [Aur:1] pacback-2.0.2-0

1 pacback (Installed) (Build Files Exist) ==> Packages to cleanBuild? ==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4) ==> a :: Deleting (1/1): /home/cycode/.cache/yay/pacback :: Downloaded PKGBUILD (1/1): pacback 1 pacback (Installed) (Build Files Exist) ==> Diffs to show? ==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4) ==> n :: (1/1) Parsing SRCINFO: pacback ==> Erstelle Paket: pacback 2.0.2-0 (Sa 12 Sep 2020 17:20:19 CEST) ==> Empfange Quellen... -> Lade pacback-2.0.2-SOURCE.tar.zst herunter... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 654 100 654 0 0 3613 0 --:--:-- --:--:-- --:--:-- 3593 100 28016 100 28016 0 0 26134 0 0:00:01 0:00:01 --:--:-- 26134 ==> Überprüfe source Dateien mit sha512sums... pacback-2.0.2-SOURCE.tar.zst ... Durchgelaufen ==> Erstelle Paket: pacback 2.0.2-0 (Sa 12 Sep 2020 17:20:21 CEST) ==> Prüfe Laufzeit-Abhängigkeiten... ==> Prüfe Buildtime-Abhängigkeiten... ==> Empfange Quellen... -> pacback-2.0.2-SOURCE.tar.zst gefunden ==> Überprüfe source Dateien mit sha512sums... pacback-2.0.2-SOURCE.tar.zst ... Durchgelaufen ==> Entferne existierendes $srcdir/ Verzeichnis... ==> Entpacke Quellen... -> Entpacke pacback-2.0.2-SOURCE.tar.zst mit bsdtar ==> Quellen sind fertig. ==> Erstelle Paket: pacback 2.0.2-0 (Sa 12 Sep 2020 17:20:23 CEST) ==> Prüfe Laufzeit-Abhängigkeiten... ==> Prüfe Buildtime-Abhängigkeiten... ==> WARNUNG: Verwende bestehenden $srcdir/ Baum ==> Betrete fakeroot Umgebung... ==> Beginne package()... ==> Säubere Installation... -> Entferne libtool Dateien... -> Bereinige ungewollte Dateien... -> Entferne statische Bibliotheken... -> Entferne unnötige Symbole aus Binär-Dateien und Bibliotheken... -> Komprimiere Man-Pages und Info-Seiten... ==> Prüfe auf Paketierungsprobleme... ==> Erstelle Paket "pacback"... -> Erstelle .PKGINFO Datei... -> Erstelle .BUILDINFO Datei... -> Füge install Datei hinzu... -> Erstelle .MTREE-Datei... -> Komprimiere Paket... ==> Verlasse fakeroot Umgebung. ==> Beendete Erstellung: pacback 2.0.2-0 (Sa 12 Sep 2020 17:20:25 CEST) ==> Räume auf... [sudo] Passwort für cycode: Lade Pakete... Warnung: pacback-2.0.2-0 ist aktuell -- Reinstalliere Löse Abhängigkeiten auf... Suche nach in Konflikt stehenden Paketen...

Pakete (1) pacback-2.0.2-0

Gesamtgröße der installierten Pakete: 0,10 MiB Größendifferenz der Aktualisierung: 0,00 MiB

:: Installation fortsetzen? [J/n] (1/1) Prüfe Schlüssel im Schlüsselring [#########################################################################] 100% (1/1) Überprüfe Paket-Integrität [#########################################################################] 100% (1/1) Lade Paket-Dateien [#########################################################################] 100% (1/1) Prüfe auf Dateikonflikte [#########################################################################] 100% (1/1) Überprüfe verfügbaren Festplattenspeicher [#########################################################################] 100% Warnung: konnte Dateiinformationen für tmp/alpha-upgrade.sh nicht ermitteln :: Verarbeite Paketänderungen... (1/1) Installiere pacback [#########################################################################] 100% find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback’: Datei oder Verzeichnis nicht gefunden find: ‘/var/lib/pacback/restore-points’: Datei oder Verzeichnis nicht gefunden :: Starte post-transaction hooks... (1/1) Arming ConditionNeedsUpdate... Traceback (most recent call last): File "/usr/bin/pacback", line 88, in user.list_all(config) File "/usr/share/pacback/core/user.py", line 47, in list_all rps = sorted(m for m in paf.scan_dir(config['rp_paths'])[0] if m.endswith('.meta')) File "/usr/share/pacback/core/paf/file.py", line 19, in scan_dir for x in os.scandir(path): FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/pacback/restore-points' `

CyCodeDE commented 4 years ago

Whoops accidently closed it

JustinTimperio commented 4 years ago

So I am relying on google translate here but this doesn't have to deal with pacback session locks but is a build package and install issue as I suspected. I have finally been able to reproduce this issue and it's such a stupid mistake on my part.

Previously, pacback expected sudo for every command, so when the path /var/lib/pacback was missing, it could be easily created. But because I changed this and also implemented these lines of code in the new lock system, when pacback tries to create a lock file it can't because the folder doesn't exist, and except OSError catches this and reports it as an active session. The same also happens during pacback -ls which looks for that folder and can't find it.

Thankfully this is an insanely simple fix I need to make to the buildpkg. I am going to make some quick edits and test this now. Thanks for helping me figure this one out.

CyCodeDE commented 4 years ago

Now it works, thank you!

JustinTimperio commented 4 years ago

Okay, so I've patched this issue with version 2.0.3. The issue was my own oversite not fixing the build and install process for new users after modifying the session lock and the removal of certain root requirements.

@mirh Funnily enough, this error literally only occurred with new installs. If you were performing an upgrade all the folders would have existed preventing the error from occurring.