Skip to content

[Bug] @huggingface/transformers model cache writes inside read-only asar, memory indexing fails with ENOTDIR #88

Closed

Description

@Shackbear

Environment

  • macOS Apple Silicon (arm64)
  • Memmy v1.0.3 (unsigned DMG built from source)
  • Dependency: @huggingface/transformers (Xenova/all-MiniLM-L6-v2 model)

Description

After fixing the dylib issue (#76), the memory service starts but indexing fails when it tries to download and cache the embedding model. The @huggingface/transformers library attempts to create a .cache/ directory inside the module's path, which resolves to inside the read-only app.asar archive.

Error

ENOTDIR: not a directory, mkdir '/Applications/Memmy.app/Contents/Resources/app.asar/dist/runtime/memory/node_modules/@huggingface/transformers/.cache/Xenova/all-MiniLM-L6-v2/onnx'

Root Cause

In Memory/src/model/embedder.ts, the ensureLocalExtractor function loads the model via:

const mod = await import("@huggingface/transformers");
const pipeline = mod.pipeline;
return await pipeline("feature-extraction", model, { dtype: "q8", device: "cpu" });

No cache_dir or env.cacheDir is configured, so the library defaults to .cache/ relative to the module directory. Inside a packaged Electron app, this path is inside the read-only asar archive.

Workaround

Patch the compiled embedder.js to set a writable cache directory before loading the pipeline:

const mod = await import("@huggingface/transformers");
const { homedir } = await import("node:os");
const { join } = await import("node:path");
mod.env.cacheDir = join(homedir(), ".memmy", "transformers-cache");

Suggested Fix

In Memory/src/model/embedder.ts, set env.cacheDir to a writable location (e.g., ~/.memmy/transformers-cache or the app's userData directory) before calling pipeline(). This ensures the model cache survives app updates and is writable in packaged builds.

Activity

  1. self-assigned this
    on Aug 4, 2026
  2. hijzy commented on Aug 4, 2026

    @hijzy
    Collaborator

    Fixed by #102 (commit 514d963) and included in main via #112.

    The Transformers model cache is now explicitly configured to use the writable
    directory ~/.memmy/memory-service/model-cache, so packaged Electron builds no
    longer attempt to write inside app.asar.

    The regression test passes on the current main. Closing as completed.

    Thanks for the detailed report!

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions