Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock-file error-handling - suggest switch to graceful exit #8

Closed
jmetz opened this issue Mar 8, 2024 · 1 comment · Fixed by #9
Closed

Lock-file error-handling - suggest switch to graceful exit #8

jmetz opened this issue Mar 8, 2024 · 1 comment · Fixed by #9
Labels
bug Something isn't working

Comments

@jmetz
Copy link

jmetz commented Mar 8, 2024

When lock-file exists, currently https://github.com/VoltaireNoir/blight/blob/main/src/utils.rs#L374-L378 causes a panic:

./blight inc 10 
Error A panic occured
Reason failed to open lock file: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
Location src/utils.rs:378:10
Tip This is unexpected behavior. Please report this issue at https://github.com/VoltaireNoir/blight/issues
fish: Job 1, './blight inc 10' terminated by signal SIGABRT (Abort)

Most applications with lock-files that I've used tend to exit gracefully, as this kind of thing does happen from time-to-time.

Recommend switching from expect and the resulting panic, to matching the failure and reporting a less panicky message to the user along the lines of eg pacman:

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

Background

I just installed and ran this on an arch-type system, and probably did something wrong at some point resulting in the stray lock-file.

@VoltaireNoir
Copy link
Owner

Thank you for reporting the issue. You're right about turning this into a normal error instead of making the program panic. I'll make fix it and cut a new release soon.

@VoltaireNoir VoltaireNoir added the bug Something isn't working label Mar 8, 2024
@VoltaireNoir VoltaireNoir linked a pull request Mar 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants