Summary
scip-python index crashes on Windows before indexing starts because path.sep is used directly in new RegExp(...).
On Windows, path.sep === \, so this produces an invalid regular expression:
Invalid regular expression: /\\/g: \\ at end of pattern
Repro
Environment:
- Windows 11
- Node.js 24.12.0
@sourcegraph/scip-python@0.6.6
Command:
scip-python index --cwd D:\\Development\\Prompsit\\prompsit-api --project-name prompsit-api
Observed stack trace points to packages/pyright-scip/src/virtualenv/PythonEnvironment.ts:
const pathSepRegex = new RegExp(path.sep, 'g');
Expected
scip-python should index successfully on Windows.
Root Cause
path.sep must be escaped before it is used as a regex pattern.
Proposed Fix
Replace:
const pathSepRegex = new RegExp(path.sep, 'g');
with an escaped variant, for example:
const pathSepRegex = new RegExp(path.sep.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g');
I have locally verified that this removes the Windows crash and allows scip-python index to complete on a real project.
Summary
scip-python indexcrashes on Windows before indexing starts becausepath.sepis used directly innew RegExp(...).On Windows,
path.sep === \, so this produces an invalid regular expression:Repro
Environment:
@sourcegraph/scip-python@0.6.6Command:
Observed stack trace points to
packages/pyright-scip/src/virtualenv/PythonEnvironment.ts:Expected
scip-pythonshould index successfully on Windows.Root Cause
path.sepmust be escaped before it is used as a regex pattern.Proposed Fix
Replace:
with an escaped variant, for example:
I have locally verified that this removes the Windows crash and allows
scip-python indexto complete on a real project.