Skip to content

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

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.

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