fix: set env.cacheDir to user-writable location#845
Merged
magyargergo merged 1 commit intoApr 15, 2026
Conversation
When @huggingface/transformers is installed globally (e.g. via npm install -g), it defaults its cache directory to ./node_modules/.cache inside its own install dir, which is unwritable by non-root users. This causes EACCES errors on first use when the model is downloaded: EACCES: permission denied, mkdir '/usr/lib/node_modules/gitnexus/node_modules/@huggingface/transformers/.cache' Set env.cacheDir before pipeline() is called in both embedders (CLI and MCP). Respects HF_HOME env var if set, falls back to ~/.cache/huggingface.
|
Someone is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
this PR fixes #844 |
Collaborator
|
Nice fix! :) |
Contributor
CI Report✅ All checks passed Pipeline Status
Test Results
✅ All 6257 tests passed 97 test(s) skipped — expand for details
Code CoverageTests
📋 View full run · Generated by CI |
Collaborator
|
Thank you for your contribution! |
github714801013
pushed a commit
to github714801013/GitNexus
that referenced
this pull request
Apr 28, 2026
When @huggingface/transformers is installed globally (e.g. via npm install -g), it defaults its cache directory to ./node_modules/.cache inside its own install dir, which is unwritable by non-root users. This causes EACCES errors on first use when the model is downloaded: EACCES: permission denied, mkdir '/usr/lib/node_modules/gitnexus/node_modules/@huggingface/transformers/.cache' Set env.cacheDir before pipeline() is called in both embedders (CLI and MCP). Respects HF_HOME env var if set, falls back to ~/.cache/huggingface. Co-authored-by: Sisyphus <sisyphus@gitnexus.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
@huggingface/transformersis installed globally (e.g. vianpm install -g), it defaults its cache directory to./node_modules/.cacheinside its own install dir — which is unwritable by non-root users.This causes an
EACCESerror on first use when the model is downloaded:Root Cause
transformers.jsdefaultsenv.cacheDirto{package_install_dir}/.cache/. It does not respectHF_HOMEorTRANSFORMERS_CACHEenv vars (those are for the Python library). Only the programmaticenv.cacheDirsetting works.GitNexus sets
env.allowLocalModels = falsein both embedders but never configuresenv.cacheDir.Fix
Set
env.cacheDirbeforepipeline()is called in both embedders:gitnexus/src/mcp/core/embedder.tsgitnexus/src/core/embeddings/embedder.tsRespects
HF_HOMEif set, otherwise falls back to~/.cache/huggingface.Testing
env.cacheDirassignment pattern matches existingenv.allowLocalModelsusage in the same files