Skip to content

Windows: scip-python crashes on startup due to unescaped path.sep in RegExp #210

Description

@levnikolaevich

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions