From de42c289c7b2c7ccd11af02373eb6fd90230d1a7 Mon Sep 17 00:00:00 2001 From: chrimage Date: Mon, 16 Jun 2025 17:44:22 -0500 Subject: [PATCH] fix: resolve installer "Source and destination must not be the same" error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue where npx bmad-method install would fail with "Source and destination must not be the same" when installing to the default .bmad-core directory. Changes: - Update getBmadCorePath() to use absolute path resolution - Add safety check in installer to detect and prevent same-source-destination copies - Provide clear error message when paths are identical 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tools/installer/lib/config-loader.js | 8 +++++++- tools/installer/lib/installer.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/installer/lib/config-loader.js b/tools/installer/lib/config-loader.js index 8aeb5ad6..1b6169dc 100644 --- a/tools/installer/lib/config-loader.js +++ b/tools/installer/lib/config-loader.js @@ -78,7 +78,13 @@ class ConfigLoader { getBmadCorePath() { // Get the path to .bmad-core relative to the installer (now under tools) - return path.join(__dirname, '..', '..', '..', '.bmad-core'); + // When running via npx, __dirname points to the installed package + // We need to find the actual .bmad-core directory that comes with the package + const packageRoot = path.join(__dirname, '..', '..', '..'); + const bmadCorePath = path.join(packageRoot, '.bmad-core'); + + // Resolve to absolute path to avoid "same source and destination" issues + return path.resolve(bmadCorePath); } getAgentPath(agentId) { diff --git a/tools/installer/lib/installer.js b/tools/installer/lib/installer.js index 6e43b9dd..d7ea850e 100644 --- a/tools/installer/lib/installer.js +++ b/tools/installer/lib/installer.js @@ -200,7 +200,13 @@ class Installer { // Full installation - copy entire .bmad-core folder as a subdirectory spinner.text = "Copying complete .bmad-core folder..."; const sourceDir = configLoader.getBmadCorePath(); - const bmadCoreDestDir = path.join(installDir, ".bmad-core"); + const bmadCoreDestDir = path.resolve(path.join(installDir, ".bmad-core")); + + // Check if source and destination are the same to prevent copy errors + if (path.resolve(sourceDir) === bmadCoreDestDir) { + throw new Error(`Cannot install to ${bmadCoreDestDir} - it's the same as the source directory. Please choose a different installation directory.`); + } + await fileManager.copyDirectory(sourceDir, bmadCoreDestDir); // Get list of all files for manifest