.lock

What is a .lock file?

Dependency Lockfile / Lock Marker · Code and data

A .lock file is usually a dependency lockfile (yarn.lock, Cargo.lock, Gemfile.lock, composer.lock) that pins exact package versions, or a temporary marker a program creates to signal a resource is in use.

Category
Code and data
MIME type
Type
Plain text
Is a .lock file safe to open? Safe. Lockfiles are generated text (or empty markers) and do not execute. Do not hand-edit dependency lockfiles; regenerate them with the package manager instead.

What is a .lock file used for?

Package managers write lockfiles so every install resolves to exactly the same dependency tree: the manifest says what you want, the lockfile records what you got, down to versions and checksums. They are generated files, edited by tools, not by hand.

The second meaning is a lock marker: an often-empty file (for example on a database or a running app's profile directory) that prevents two processes using the same resource. Those can be deleted safely only when the owning program is not running.

What opens a .lock file?

The .lock format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.

Windows

  • any text editor (to inspect)

macOS

  • any text editor (to inspect)

Linux

  • any text editor (to inspect)

Open a .lock file step by step

  1. Confirm the file really is a .lock. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with any text editor (to inspect).
  3. On Mac, use any text editor (to inspect).
  4. On Linux, try any text editor (to inspect).
  5. Still stuck? Search for a dedicated Lockfile viewer rather than a generic one.

Why can't I open my .lock file?

Almost always because no installed app understands Lockfile. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .lock at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

Lockfile has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

Frequently asked questions

What is a .lock file?

A .lock file is usually a dependency lockfile (yarn.lock, Cargo.lock, Gemfile.lock, composer.lock) that pins exact package versions, or a temporary marker a program creates to signal a resource is in use.

Should I commit lockfiles to git?

For applications, yes: yarn.lock, Cargo.lock and friends guarantee identical installs for the whole team and CI. Libraries sometimes leave them out; follow your ecosystem's convention.

Can I delete a .lock file?

A dependency lockfile: only if you intend to re-resolve all versions on the next install. A lock marker: only when the program that created it is not running, otherwise it is protecting something.

Why does my install fail with a lockfile conflict?

The manifest and the lockfile disagree, often after a merge. Re-run the package manager's install/update so it reconciles and rewrites the lockfile, then commit the result.

Related formats

Sources

Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.