From 32ea4f542b8e7262b0f03459e2a43963cbb2ab0c Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 8 Sep 2021 16:03:16 +0300 Subject: [PATCH] fix: a human-readable error when lock cannot be acquired (#8768) Fixes #8709 --- src/utils/registry.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/utils/registry.ts b/src/utils/registry.ts index 5a32fd353f..e26074e7d2 100644 --- a/src/utils/registry.ts +++ b/src/utils/registry.ts @@ -562,6 +562,25 @@ export class Registry { else throw new Error(`ERROR: Playwright does not support installing ${executable.name}`); } + } catch (e) { + if (e.code === 'ELOCKED') { + const rmCommand = process.platform === 'win32' ? 'rm -R' : 'rm -rf'; + throw new Error('\n' + wrapInASCIIBox([ + `An active lockfile is found at:`, + ``, + ` ${lockfilePath}`, + ``, + `Either:`, + `- wait a few minutes if other Playwright is installing browsers in parallel`, + `- remove lock manually with:`, + ``, + ` ${rmCommand} ${lockfilePath}`, + ``, + `<3 Playwright Team`, + ].join('\n'), 1)); + } else { + throw e; + } } finally { await releaseLock(); }