Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for Windows long paths #2040

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/core/engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import {
loadScript,
loadPageCompleteScript
} from '../../support/engineUtils.js';

import { checkWindowsLongPath } from '../../support/windows.js';

const log = intel.getLogger('browsertime');
const defaults = {
scripts: [],
Expand Down Expand Up @@ -283,6 +286,7 @@ export class Engine {
options
);

await checkWindowsLongPath();
await storageManager.createDataDir();
await engineDelegate.beforeBrowserStart(name, options);
const collector = new Collector(name, storageManager, options);
Expand Down
20 changes: 20 additions & 0 deletions lib/support/windows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { execa } from 'execa';

import intel from 'intel';
const log = intel.getLogger('browsertime');

export async function checkWindowsLongPath() {
if (process.platform === 'win32') {
const { stdout } = await execa(
'(Get-ItemProperty "HKLM:System\\CurrentControlSet\\Control\\FileSystem").LongPathsEnabled',
{
shell: 'powershell.exe'
}
);
if (stdout === '0') {
log.info(
'LongPaths is not enabled and that can make testing fail. Read https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry on how to enable long paths'
);
}
}
}