From aef875e61ae3ffc0cb2069ddf9eb3778d9722546 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 10 Dec 2024 17:23:57 +0100 Subject: [PATCH] fix(composer): Always allow to create lockfiles The `composer.json` might have the `lock` option [1] (which defaults to `true`) explicitly set to `false` to disallow the creation of lockfiles. Previously, analyzing such projects resulted in Composer failed to resolve dependencies for path 'composer.json': FileNotFoundException: /tmp/.../composer.lock (No such file or directory) because the implementation relies on either a lockfile to be present or to be able to create one via `composer update` in order to parse it. But if Composer is configured to work without a lockfile, none would be created, resulting in the above error. Fix this by unsetting the `lock` option before the call to `compose update`. Unsetting the option instead of setting it to `false` has the advantage that `composer.json` files without the setting are not modified. [1]: https://getcomposer.org/doc/06-config.md#lock Signed-off-by: Sebastian Schuberth --- plugins/package-managers/composer/src/main/kotlin/Composer.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/package-managers/composer/src/main/kotlin/Composer.kt b/plugins/package-managers/composer/src/main/kotlin/Composer.kt index 4690efe20cb25..3a0541c97fd6b 100644 --- a/plugins/package-managers/composer/src/main/kotlin/Composer.kt +++ b/plugins/package-managers/composer/src/main/kotlin/Composer.kt @@ -248,6 +248,9 @@ class Composer( requireLockfile(workingDir) { hasLockfile } if (hasLockfile) return lockfile + // Ensure that the build is not configured to disallow the creation of lockfiles. + run(workingDir, "--no-interaction", "config", "--unset", "lock").requireSuccess() + val composerVersion = Semver(getVersion(workingDir)) val args = buildList { add("--no-interaction")