Windows: chub get fails with ENOENT on mkdir due to forward-slash path splitting
Author: omerneshCreated Mar 20, 2026Updated Mar 27, 2026
Bug
chub get <id> fails on Windows with:
Error: Failed to load "anthropic/package": ENOENT: no such file or directory, mkdir ''
Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76Root Cause
In src/lib/cache.js, line 190:
const dir = cachedPath.substring(0, cachedPath.lastIndexOf('/'));On Windows, cachedPath uses backslashes (e.g. C:\Users\...\.chub\sources\default\data\anthropic\docs\package\python\DOC.md), so lastIndexOf('/') returns -1, making dir an empty string ''. Then mkdirSync('', { recursive: true }) throws ENOENT.
Fix
Replace the manual string splitting with dirname() which is already imported at the top of the file:
- const dir = cachedPath.substring(0, cachedPath.lastIndexOf('/'));
- mkdirSync(dir, { recursive: true });
+ mkdirSync(dirname(cachedPath), { recursive: true });dirname() from node:path correctly handles both / and \ separators.
Environment
- Windows 11
- Node.js v22
@aisuite/chubv0.1.3
Notes
chub search and chub update work fine — only chub get is affected (when fetching from CDN for the first time, triggering the cache write path).
Source: andrewyng/context-hub