Skip to content

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

Open

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

  1. linear commented on Apr 4, 2026

    @linear
  2. ottawa-dan commented on Nov 15, 2026

    @ottawa-dan

    Still reproduces on @sourcegraph/scip-python@0.6.8 (Windows 11, Node 20.19.5): scip-python index exits at startup with SyntaxError: Invalid regular expression: /\/g: \ at end of pattern from PythonEnvironment.ts:4, before any file is read. The same command and version index the same project without error on Linux x86_64. #224 looks like it covers this.

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

      ⌂ Proxy