bm doctor fails when BASIC_MEMORY_PROJECT_ROOT equals the project directory · Issue #1323 · basicmachines-co/basic-memory · GitHub
Skip to content

bm doctor fails when BASIC_MEMORY_PROJECT_ROOT equals the project directory #1323

Closed

Description

@benjaminfrombe

Summary

bm doctor cannot run when BASIC_MEMORY_PROJECT_ROOT points at the project directory itself. It tries to create a temporary project inside the project root, which the nesting guard then rejects.

Environment

  • Basic Memory 0.23.0 (ghcr.io/basicmachines-co/basic-memory:latest)
  • Docker, SQLite backend, single project

Relevant environment:

environment:
  - BASIC_MEMORY_DEFAULT_PROJECT=benjamin
  - BASIC_MEMORY_HOME=/app/data/benjamin
  - BASIC_MEMORY_PROJECT_ROOT=/app/data/benjamin
volumes:
  - ./data:/app/data

Steps to reproduce

basic-memory doctor

Actual

Running Basic Memory doctor checks...
Doctor failed: Cannot create project at '/app/data/benjamin/doctor-d86fb537':
path is nested within existing project 'benjamin' at '/app/data/benjamin'.
Projects cannot share directory trees.

Expected

doctor runs its consistency checks, or at minimum degrades gracefully instead of failing outright.

Analysis

doctor creates a scratch project (doctor-<random>) to run its checks. That scratch project is created under BASIC_MEMORY_PROJECT_ROOT. When PROJECT_ROOT is the same path as the project's own directory, the scratch project lands inside the existing project, and the "projects cannot share directory trees" guard correctly refuses.

The two settings are independently valid on their own, so the combination is easy to end up with: HOME naming the project directory and PROJECT_ROOT constraining where projects may live.

Possible fixes

  • Create the scratch project in a real temporary directory (for example tempfile.mkdtemp()) rather than under PROJECT_ROOT.
  • Or exempt the doctor scratch project from the nesting guard.
  • Or detect the PROJECT_ROOT == project path case and skip the scratch project, running the checks against the existing project directly.

Workaround

Setting BASIC_MEMORY_PROJECT_ROOT to the parent directory (/app/data) should avoid it, but that changes how project paths resolve for an existing installation, so it is not a free change for anyone already running this layout.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions