Lock dependencies and pin Composer
- Created
- Decided
- Versions
- History
Context
composer.lock is gitignored, and every CI job runs composer self-update && composer install && composer dump-autoload. Each run resolves dependencies afresh, against a Composer binary that moves as well. A transitive
release can turn the build red overnight with no local change, and PHPStan or php-cs-fixer can behave differently in CI
than they do locally.
Committing the lock file is the standard, recommended practice for a project: everyone who sets the project up, CI included, then runs exactly the same dependency versions.
Decision
I will commit composer.lock and have CI install from it with composer install --no-interaction --no-progress. CI
will run a pinned Composer version, the same one used locally, and the pin will only change deliberately.
Alternatives
Resolving dependencies afresh on every CI run, with the lock file ignored and Composer updating itself first. I rejected this because it lets a build break with no local change, and lets tools behave differently in CI than they do locally.
Consequences
Easier:
- Every CI job will install the versions in the committed lock file, the same ones used locally, so a build will not break without a local change and tools will behave the same in CI as they do locally.
- CI will no longer need
composer dump-autoload, sincecomposer installgenerates the autoloader.
Harder:
- Updating Composer will be a deliberate change to the pin. A vulnerable Composer will stay pinned until someone moves it, so Composer's security releases will need acting on.
Constrained:
- The declared lower bounds of dependencies will not be tested. A
--prefer-lowestmatrix leg to keep them honest will be a separate change.
Sources
- PR #50, chore(engine): Tooling, CI and documentation cleanup, opened and merged , squashed as
54dcfb0: the problem, the decision, the alternative and the consequences other than Composer's security releases.
Its commit message and diff record the lock file and pin changes.
createdis when it was opened anddecidedwhen it merged. - PR #75, chore: Rename package, add licence and patch Composer CVE, merged and squashed as 3372f20: the consequence for Composer's security releases, taken from what followed rather than anticipated. It moved the pin from 2.9.3 to 2.10.3 because 2.9.3 is inside the range affected by CVE-2026-84361, which had left CI running a Composer open to arbitrary command execution through a package's Perforce source URL.
- Composer documentation, Basic usage, "Commit your composer.lock file to version control", read : committing the lock file as the standard practice for projects, and why.
Source adr/0015-locked-dependencies.md · commit d6910e4 · exported