Skip to content

[Bug]: Cannot create collection on C: drive on Windows #333

@Saiyuekin

Description

@Saiyuekin

Description

Bug Report: Cannot create collection on C: drive on Windows

Description

zvec 0.3.0 fails to create a collection on any path on the C: drive on Windows. The error message shows:

ValueError: create collection path failed: C:\...\zvec_index, error: No error

Interestingly, the error message says "error: No error", which is confusing and suggests the underlying error handling might not be properly implemented for Windows.

Environment

  • OS: Windows 11 Pro
  • Python: 3.12.12
  • zvec: 0.3.0 (latest version from PyPI)
  • CPU Architecture: x86_64

Additional Information

Tested Paths on C: Drive (All Failed)

Path Result
C:\Users\MyWork\AppData\Local\Temp\zvec_test Failed
C:\Users\MyWork\sc\zvec_index Failed
C:\sc\zvec_index Failed

Tested Paths on Other Drives (All Succeeded)

Path Result
D:\sc\zvec_index Success
D:\my_custom_index Success

Workaround

Currently, the only workaround is to use a non-C: drive path:

import zvec
from pathlib import Path

# Use D: drive instead
index_path = Path("D:/sc/zvec_index")
index_path.mkdir(parents=True, exist_ok=True)

# This works
collection = zvec.create_and_open(str(index_path), schema)

Possible Root Cause

Based on the error message "error: No error", it seems like:

  1. The underlying C++ code might not be properly handling Windows-specific path operations on the C: drive
  2. The error code from the Windows API might not be correctly translated to a meaningful error message
  3. There might be some special handling or restrictions for the C: drive that are not accounted for

Related Issues

Full Reproduction Script

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
zvec C: drive issue reproduction script
"""

import sys
import os
import traceback
from pathlib import Path

# Windows console UTF-8 encoding support
if sys.platform == "win32":
    sys.stdout.reconfigure(encoding="utf-8")

# ============================================================
# Configuration
# ============================================================
DATA_DIR = Path("C:/Users/MyWork/sc")


def create_vector_index(dimension: int = 128):
    """
    Create zvec vector index in DATA_DIR.
    """
    import uuid
    import shutil

    try:
        import zvec
    except ImportError:
        raise RuntimeError("zvec not installed. Run: pip install zvec>=0.3.0")

    index_path = DATA_DIR / "zvec_index"
    session_path = index_path / f"session_{uuid.uuid4().hex[:8]}"

    if session_path.exists():
        shutil.rmtree(session_path, ignore_errors=True)

    session_path.parent.mkdir(parents=True, exist_ok=True)

    print(f"[Info] Index path: {session_path}")

    # Create Schema
    content_field = zvec.FieldSchema("content", zvec.DataType.STRING)
    vector_field = zvec.VectorSchema(
        name="embedding",
        data_type=zvec.DataType.VECTOR_FP32,
        dimension=dimension,
        index_param=zvec.HnswIndexParam(m=16, ef_construction=200),
    )
    schema = zvec.CollectionSchema(
        name="test_vectors",
        fields=[content_field],
        vectors=vector_field,
    )

    # Create collection - this fails on C: drive
    collection = zvec.create_and_open(str(session_path), schema)

    print(f"[Success] Index created!")

    return collection, str(session_path)


def main():
    print("=" * 60)
    print("zvec C: drive issue reproduction")
    print(f"Path: {DATA_DIR}")
    print("=" * 60)
    print()

    try:
        collection, actual_path = create_vector_index()
        del collection
        import shutil
        if Path(actual_path).exists():
            shutil.rmtree(actual_path, ignore_errors=True)
    except Exception as e:
        print(f"\n[Error] {type(e).__name__}: {e}")
        print("\n[Stack Trace]")
        traceback.print_exc()
        return 1

    print("\n" + "=" * 60)
    print("Done!")
    print("=" * 60)
    return 0


if __name__ == "__main__":
    sys.exit(main())

Labels: bug, windows

Steps to Reproduce

1. Install zvec:
   
   pip install zvec>=0.3.0
   

2. Run the following Python code:


import zvec
from pathlib import Path

# Try to create collection on C: drive
index_path = Path("C:/Users/MyWork/sc/zvec_index")
index_path.mkdir(parents=True, exist_ok=True)
session_path = index_path / "session_test"

# Create Schema
content_field = zvec.FieldSchema("content", zvec.DataType.STRING)
vector_field = zvec.VectorSchema(
    name="embedding",
    data_type=zvec.DataType.VECTOR_FP32,
    dimension=128,
    index_param=zvec.HnswIndexParam(m=16, ef_construction=200),
)
schema = zvec.CollectionSchema(
    name="test_vectors",
    fields=[content_field],
    vectors=vector_field,
)

# This will fail on C: drive
collection = zvec.create_and_open(str(session_path), schema)


## Expected Behavior

The collection should be created successfully on the C: drive, just like it works on other drives (D:, E:, etc.).

## Actual Behavior


ValueError: create collection path failed: C:\Users\MyWork\sc\zvec_index\session_test, error: No error

Logs / Stack Trace

Traceback (most recent call last):
  File "create_index_example.py", line 144, in main
    collection, actual_path = create_vector_index()
                              ^^^^^^^^^^^^^^^^^^^^^
  File "create_index_example.py", line 78, in create_vector_index
    collection = zvec.create_and_open(str(session_path), schema)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv\Lib\site-packages\zvec\zvec.py", line 203, in create_and_open
    _collection = _Collection.CreateAndOpen(path, schema._get_object(), option)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: create collection path failed: C:\Users\MyWor\sc\zvec_index\session_test, error: No error

Operating System

Windows 11 Pro

Build & Runtime Environment

  • OS: Windows 11 Pro - Python: 3.12.12 - zvec: 0.3.0 (latest version from PyPI) - CPU Architecture: x86_64

Additional Context

  • I've checked git status — no uncommitted submodule changes
  • I built with CMAKE_BUILD_TYPE=Debug
  • This occurs with or without COVERAGE=ON
  • The issue involves Python ↔ C++ integration (pybind11)

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions