What is a lock file, and how do I unlock it? How do I unlock my files in Cadence?

What is a lock file? Why does it say that my file is locked?

File locking is a mechanism that restricts access to a computer file. For example, an application will often create a temporary file while it is open to prevent others from editing the same file. These temporary files are usually deleted when you exit your program. However, if a program crashes unexpectedly or is improperly closed, the lock files can remain and prevent you from opening the program again. These files may have the same name but start with a dot or hash, or have an extra suffix like .lck at the end, depending on which software you were running.

For example, Cadence lock files are particularly notorious for not deleting properly after a crash. When you open Cadence cells for editing, it automatically creates the temporary lock file to prevent others from editing the same file. Usually, the lock files are deleted when the layout file is saved and closed. However, if Cadence crashes or is improperly closed, the lock file may not be deleted due to the crash, and will prevent you from opening the program:

pop-up could not open

How do I fix this?

To regain access to edit your file, you will need to delete the associated lock file(s). In general, these typically end with lck or .lck. For example, Cadence lock files end with the .cdslck extension. Be careful to close the application before deleting the lock file, as it may be auto-generated.

Through the command line:

  • Navigate to your working directory in the terminal with the cd command
  • Run ls -latr to show directory listing in long format, sort by timestamp, and reverse so latest files are at the top
  • If you don't immediately see the file, try typing find . -name "*lck" to find all instances of lock files
  • Run use rm filename to remove each file individually
  • If prompted to delete, type yes, and press Enter each time
  • Check any sub-directories to make sure every lock file is gone
  • Some applications may also leave lock files in your home directory, so you should repeat these steps there to be sure all lock files are removed

Through the file explorer:

  • Navigate to your working directory in the file explorer
  • Sort the folder so latest files are at the top
  • Delete all files that end with lck or a .lck extension
  • Check any sub-directories to make sure every lock file is gone
  • Some applications may also leave lock files in your home directory, so you should repeat these steps there to be sure all lock files are removed

How do I prevent lock files from being created?

Although application crashes can't always be prevented, the best way to make sure you don't inadvertently leave a lock file is to save and exit the program properly, so the temporary lock files are automatically removed.