Bugfix: How to fix 'Source and destination must not be the same' err...

Documentation for Sessions

🐛 Bugfix: How to fix 'Source and destination must not be the same' err...

Date: 2026-02-25
Time: 21:36:03 UTC
Session: gspace1-142.7
Agent: angular
Confidence: 97%
Status: ✅ Documented


📋 Decision Context

Question:

How to fix 'Source and destination must not be the same' error in build-angular-library.js on Windows?

Task: Fix Vitto Desktop CI/CD release workflow


🎯 Decision Made

Chosen:

Replace file.replace(libPath, distPath) with path.join(distPath, path.relative(libPath, file)) for both HTML and SCSS file output path calculation.

Options Considered:

  1. path.join(distPath, path.relative(libPath, file)) (cross-platform — chosen)
  2. Normalize both paths with path.normalize() before replace
  3. Use regex replace with [/\] separator pattern
  4. Use path.posix.relative for consistent forward slashes

💭 Reasoning

On Windows, findFiles() returns paths with backslashes (e.g., 'libs\libs-ux\ux-utils-lib\src\file.html') but libPath uses forward slashes ('libs/libs-ux/ux-utils-lib'). String.replace() doesn't match because the separators differ, so outputPath equals the input path (no substitution). fs.copy() then fails because source === destination. Using path.relative() + path.join() is cross-platform — path.relative() handles mixed separators correctly, and path.join() uses the OS-native separator.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation