You are not logged in.

#1 2017-01-01 19:45:05

ElectricPrism
Member
Registered: 2012-12-07
Posts: 35

Sharing my "pacman-unlock" SH

Create file with contents:
`/usr/bin/unlock-pacman`

#!/bin/sh
sudo rm /var/lib/pacman/db.lck

Set Permissions to Executable

sudo chmod 0755 /usr/bin/unlock-pacman

Now we can issue unlock-pacman instead of sudo rm [....] which helps deture accidental deletion from user input error.

I know it's simplistic but I thought I would share.

Offline

#2 2017-01-01 19:55:34

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: Sharing my "pacman-unlock" SH

Could one not also use a Bash Alias for such a simple one-liner? In ~/.bashrc...

alias unlock-pacman='sudo rm var/lib/pacman/db.lck'

Also, this is really trivial to do and already covered in the wiki: https://wiki.archlinux.org/index.php/Pa … 9.22_error. Not sure what that means for this thread...


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#3 2017-01-01 20:03:43

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Sharing my "pacman-unlock" SH

This also raises the question why are you having to run this command so often?

I've been running Arch on several machines for years and have never once seen the locked database error.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#4 2017-01-01 20:08:31

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: Sharing my "pacman-unlock" SH

Good point. The easiest way to trigger the error is the following: In Terminal 1, run the following: sudo pacman -Syu. In a second terminal, run the following: sudo pacman -S <software>, in my case, I chose xterm at random. The error appears:

... With a pacman -Syu running in a second terminal ...
[jbs@dmb-gaming-laptop ~]$ sudo pacman -S xterm
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
  if you're sure a package manager is not already
  running, you can remove /var/lib/pacman/db.lck
[jbs@dmb-gaming-laptop ~]$ 

Granted, if you have a system update actively running, you should *never* remove the lock!


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#5 2017-01-01 23:45:14

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: Sharing my "pacman-unlock" SH

JohnBobSmith wrote:

Good point. The easiest way to trigger the error is the following: In Terminal 1, run the following: sudo pacman -Syu. In a second terminal, run the following: sudo pacman -S <software>, in my case, I chose xterm at random. The error appears:

[...]

Granted, if you have a system update actively running, you should *never* remove the lock!

You're describing the exact reason why the lock exists: to prevent concurrent modification of the database.
So yes, there really is no reason why one would ever want to remove that lock.

... unless there is a crash of pacman or an underlying system. Which, under normal circumstances, shouldn't happen so often that it would require an automated workaround solution (→ slithery's question).


pkgshackscfgblag

Offline

#6 2017-01-02 03:02:23

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,356

Re: Sharing my "pacman-unlock" SH

It can be useful with slower connections as pacman locks on starting downloads. Removing the lock when I know there's going to be enough time allows me to compile an AUR package (or 5) while waiting for downloads to complete.

I believe the lock should really be released during downloads, but it isn't.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#7 2017-01-02 07:09:38

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Sharing my "pacman-unlock" SH

The lock during download prevents multiple pacman instances trying to download the same file  (which could be fixed by allowing more fine grained locking...)

Offline

#8 2017-01-02 10:13:08

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,356

Re: Sharing my "pacman-unlock" SH

Allan wrote:

The lock during download prevents multiple pacman instances trying to download the same file  (which could be fixed by allowing more fine grained locking...)

Oh, I thought the *.part files should be useable for that. Then again there'd be a race condition I suppose.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#9 2017-01-02 23:04:28

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: Sharing my "pacman-unlock" SH

Can't use .part fils for that.   You could not tell a difference between a download that was interrupted and needs continued, or a download that is ongoing.

Offline

Board footer

Powered by FluxBB