Conversation
…works under node
`mount` crashes on a fresh install with `ERR_INVALID_ARG_TYPE` whenever
~/.crm/bin/crm-fuse (or crm-nfs) doesn't already exist:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at join (node:path:1269:7)
at mountLinux (.../dist/cli.js:3414:21)
Two compounding causes:
1. `import.meta.dir` is a Bun-only extension; under the published bin's
`#!/usr/bin/env node` shebang it's `undefined`, so
`join(import.meta.dir, '..', 'fuse-helper.c')` throws before it can do
anything useful.
2. `package.json#files` is `["dist", "README.md", "LICENSE"]`, so even with
a working path resolver the FUSE/NFS sources aren't shipped to npm —
the auto-compile step has nothing to compile.
Fix:
- Replace `import.meta.dir` with `dirname(fileURLToPath(import.meta.url))`,
which works under both Bun and Node.
- Add a `resolveAsset(name)` helper that looks for shipped sources in
`BUNDLE_DIR/<name>` (bundle mode) and `BUNDLE_DIR/../<name>` (source
mode), and update `mountLinux` and `mountDarwin` to use it.
- Have the build copy `src/fuse-helper.c` and `src/nfs-server/` into
`dist/` so they sit next to the bundled `cli.js` and ship via the
existing `"files": ["dist"]` entry — no `package.json#files` change
needed.
Verified end-to-end on a fresh sandbox (no pre-existing helper):
`node dist/cli.js mount /tmp/x` now compiles `~/.crm/bin/crm-fuse` and
mounts successfully.
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.
Repro
On a fresh install with no pre-existing
~/.crm/bin/crm-fuse:Root cause
Two compounding bugs:
dist/cli.jsruns under#!/usr/bin/env node, butmountLinux/mountDarwincalljoin(import.meta.dir, '..', '<asset>')to find the helper source.import.meta.diris a Bun-only extension; under Node it'sundefined, sojointhrows before the rest of the auto-compile path can run.Even with a working path resolver, the auto-compile path can't find the source —
package.json#filesships only["dist", "README.md", "LICENSE"], sosrc/fuse-helper.candsrc/nfs-server/aren't in the published npm tarball at all.Fix
import.meta.dirwithdirname(fileURLToPath(import.meta.url)), which works under both Bun and Node.resolveAsset(name)helper that looks for the asset inBUNDLE_DIR/<name>(bundle mode) andBUNDLE_DIR/../<name>(source mode), and use it in bothmountLinuxandmountDarwin.buildscript to copysrc/fuse-helper.candsrc/nfs-server/intodist/, so they sit next to the bundledcli.jsand ship via the existing"files": ["dist"]entry. Nopackage.json#fileschange needed — only one source of truth for what's published.Verification
bun run build— clean.bun run check-types— clean.test/fuse-smoke/smoke.ts— 4/4 pass.test/fuse.test.ts— 3/4 pass; the 4th test (fuse scenarios > full scenario) times out at 5s, but it does the same onmainwithout my changes (verified by stashing and re-running on main). Pre-existing test flakiness, not introduced by this PR.test/scenarios/*— same 8 timeouts onmainand on this branch (also verified by switching). Unrelated.~/.crm/bin/crm-fuse):Suggested follow-up (out of scope here)
crm mounterrors with exit 1 when called against an already-mounted path — that's intentional, but it makes idempotent setup scripts clunky. A--idempotent(or just exit 0 + a stderr note when the mountpoint is already healthy) flag would let consumers drop theirmountpoint -q X || crm mount Xguards. Happy to follow up with a separate PR if useful.🤖 Generated with Claude Code