Error: RPM failed

I keep getting this error when trying to install/uninstall anything.

Subprocess failed. Error: RPM failed: error: can’t create transaction lock on /var/lib/rpm/.rpm.lock (Inappropriate ioctl for device)

Does anyone know if there is a solution for this?

Snapper does not work, I tried to boot to few snaps and all I see is “If everything is fine use snapper rollback”

My guess is that you’re trying to remove something that is actively in use or the RPM is being managed by something else (eg You have Software Manager open while you’re trying to remove something using zypper).
You have to determine what is currently managing the file.
If it’s an application, stop the application first before removing.
If it’s a fundamental system object, then more details are needed.

Could also be a hung process or something else.
If all fails, try rebooting and trying again.
If it’s still a problem after rebooting, then that’s a clue the managing process is something started on boot and then you’d have to inspect the process more closely.