From d3c5430080666174de4a221ecaf886cd625784b1 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 7 Feb 2023 01:41:12 -0800 Subject: [PATCH] fix: reset SNAP* env variables when launching Firefox (#20692) Our builds never come from Snap, so Playwright's Firefox should never consider that it's been installed via SNAP. Fixes #20555 --------- Signed-off-by: Andrey Lushnikov Co-authored-by: Max Schmitt --- packages/playwright-core/src/server/firefox/firefox.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/playwright-core/src/server/firefox/firefox.ts b/packages/playwright-core/src/server/firefox/firefox.ts index 610ff56ab9..38c6db85d3 100644 --- a/packages/playwright-core/src/server/firefox/firefox.ts +++ b/packages/playwright-core/src/server/firefox/firefox.ts @@ -46,6 +46,12 @@ export class Firefox extends BrowserType { _amendEnvironment(env: Env, userDataDir: string, executable: string, browserArguments: string[]): Env { if (!path.isAbsolute(os.homedir())) throw new Error(`Cannot launch Firefox with relative home directory. Did you set ${os.platform() === 'win32' ? 'USERPROFILE' : 'HOME'} to a relative path?`); + if (os.platform() === 'linux') { + // Always remove SNAP_NAME and SNAP_INSTANCE_NAME env variables since they + // confuse Firefox: in our case, builds never come from SNAP. + // See https://github.com/microsoft/playwright/issues/20555 + return { ...env, SNAP_NAME: undefined, SNAP_INSTANCE_NAME: undefined }; + } return env; }