Skip to content

Commit f738f0c

Browse files
committed
fix(windows): add fallback paths for hoisted optional dependencies
- Windows binary not found due to npm hoisting optional dependencies - Add multiple search paths: nested, hoisted, and global locations - Improved error messages showing all searched paths - Fixes Windows installation where binary wasn't found Closes issue where 'cm' command failed on Windows with platform binary not found error
1 parent b54de95 commit f738f0c

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

bin/codemachine.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,30 @@ if (envBinary) {
103103
process.exit(1);
104104
}
105105

106-
// Try to find the platform-specific binary
107-
// Look in node_modules relative to this wrapper
108-
const binaryPath = join(ROOT_FALLBACK, 'node_modules', platformConfig.pkg, platformConfig.bin);
106+
// Try to find the platform-specific binary in multiple locations
107+
const searchPaths = [
108+
// 1. Nested node_modules (npm < 7 behavior)
109+
join(ROOT_FALLBACK, 'node_modules', platformConfig.pkg, platformConfig.bin),
110+
// 2. Hoisted to parent node_modules (npm >= 7 behavior, pnpm, yarn)
111+
join(ROOT_FALLBACK, '..', platformConfig.pkg, platformConfig.bin),
112+
// 3. Global install location (try to resolve from parent of codemachine)
113+
join(dirname(ROOT_FALLBACK), platformConfig.pkg, platformConfig.bin),
114+
];
109115

110-
if (!existsSync(binaryPath)) {
111-
console.error(`Error: Platform binary not found at ${binaryPath}`);
116+
let binaryPath = null;
117+
for (const path of searchPaths) {
118+
if (existsSync(path)) {
119+
binaryPath = path;
120+
break;
121+
}
122+
}
123+
124+
if (!binaryPath) {
125+
console.error(`Error: Platform binary not found. Searched:`);
126+
searchPaths.forEach((p) => console.error(` - ${p}`));
112127
console.error(`\nThe ${platformConfig.pkg} package may not be installed.`);
113128
console.error(`This is likely because your platform is not supported as an optional dependency.`);
129+
console.error(`\nTry reinstalling: npm install -g codemachine`);
114130
console.error(`\nPlease report this issue at: https://github.com/moazbuilds/CodeMachine-CLI/issues`);
115131
process.exit(1);
116132
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codemachine",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"description": "Multi-Agent Workflow Orchestration.",
55
"type": "module",
66
"bin": {
@@ -17,10 +17,10 @@
1717
"bun": "1.3.3"
1818
},
1919
"optionalDependencies": {
20-
"codemachine-linux-x64": "0.6.2",
21-
"codemachine-darwin-arm64": "0.6.2",
22-
"codemachine-darwin-x64": "0.6.2",
23-
"codemachine-windows-x64": "0.6.2"
20+
"codemachine-linux-x64": "0.6.3",
21+
"codemachine-darwin-arm64": "0.6.3",
22+
"codemachine-darwin-x64": "0.6.3",
23+
"codemachine-windows-x64": "0.6.3"
2424
},
2525
"scripts": {
2626
"_comment_dev": "Development: Run from source (no build needed)",

0 commit comments

Comments
 (0)