What is ek9.lock and should I commit it?

← Getting Started · Ref: Q2294

`ek9.lock` is written beside your main source, in the project ROOT (never under `.ek9/`), the first time a build resolves dependencies and again whenever they change. Commit it.

What it records, one fact per line:
- `declared` - a fingerprint of your package block's deps/devDeps/excludeDeps
- `minimum-compiler` - the highest minimumCompiler over the resolved set, or none
- `dependency <module> <version> production|dev <vector>` - one line per accepted dependency
- `zip <vector> <sha256>` - the library zip it was unpacked from
- `file <vector> <sha256> <path>` - one line per file copied into your project

Why commit it: while it is CURRENT - its `declared` line still matches your package block, and every file it names under `.ek9/deps/<vector>/` still hashes to what it recorded - `ek9 -c`, `-C`, `-t` and `-P` read it and never touch your library or any network. A teammate or CI builds OFFLINE, from exactly the dependency content you resolved, with no surprise substitution.

It goes stale, and the next build re-resolves, when: you edit deps/devDeps/excludeDeps; the project's own copy under `.ek9/deps/` is altered or missing (`ek9 -Cl` removes that copy, but never `ek9.lock` itself - the next `-c` restores the copy from your library and the lock is unchanged, because the hashes still agree); or this compiler is older than the lock's own `minimum-compiler` line. An UNREADABLE lock (a hand edit that leaves an unknown line, a merge conflict marker) is different: every build except `-Dp` REFUSES outright (exit code 17, "ek9.lock cannot be read") rather than silently re-resolving - fix the file, or run `ek9 -Dp` to accept it fresh.

`ek9 -Dp` always re-resolves, even when nothing changed, and is the only command that may accept library content that no longer matches a committed lock (otherwise exit code 17, naming the file that changed, until someone runs `-Dp`).

What NOT to commit: `.ek9/deps/<vector>/`, the actual copied source and resources. That lives under `.ek9/`, the build tree you already ignore - it is regenerated from your library and the lock whenever it is missing.

`ek9.lock`'s first line also pins a FORMAT VERSION: a lock written by a newer EK9 is refused by every build, `ek9 -Dp` included (exit code 17) - it is never silently downgraded, update EK9 instead. And because `ek9.lock` and `.ek9/deps/` belong to the DIRECTORY rather than to any one file, at most one top-level `.ek9` file there may declare its own `defines package` block - a second one fails resolution (exit code 17, E06265), naming both files.

See Q7 for managing dependencies. See Q10 for dev vs production dependencies. See Q14 for listing resolved dependencies.

Example

#!ek9
defines module qa.getting.started.dependency.lock.file

  defines package

    version as Version: 1.0.0-0
    description as String = "Example package showing when a build writes ek9.lock"
    license <- "MIT"
    publicAccess <- true

    tags <- [
      "example",
      "getting-started"
    ]

    applyStandardIncludes <- true

    deps <- {
      "ek9open.network.support.utils": "1.6.1-9"
    }

  defines program
    DependencyLockFileDemo()
      stdout <- Stdout()

      stdout.println("ek9.lock: commit it - it pins exactly what you build with")
      stdout.println(".ek9/deps/: never commit that - it is regenerated from the lock")
      stdout.println("Run: ek9 -Dp thisFile.ek9 to resolve and write ek9.lock")
Other ways to ask this
  • Should I commit ek9.lock to version control?
  • What does ek9.lock record?
  • Why does ek9 -c write a file called ek9.lock?
  • Is ek9.lock like package-lock.json or Cargo.lock?
  • Do I need to check in .ek9/deps/ as well as ek9.lock?

Coming from another language?

Rust: Cargo.lock - commit it for a binary. npm/yarn: package-lock.json/yarn.lock - commit it. Go: go.sum pins content hashes much like ek9.lock's file lines; go.mod is the declaration. Python: Pipfile.lock or requirements.txt with pinned versions (no official content-hash lock by default). Ruby: Gemfile.lock. EK9's ek9.lock combines the resolved-version idea of all of these with a Go-sum-style per-file content hash, and additionally pins the lowest compiler that can build the set.

Keywords: beginner, cache, cargo, checksum, commit, copy, dependencies, ek9lock, first, gosum, intro, lock, minimumCompiler, npm, offline, reproducible, sealed, sha256, start, yarn