androidnode.jscordovaionic-frameworkfs-extra

fs-extra: source and destination must not be the same. (cordova)


I get an error while building with cordova.

Error: Source and destination must not be the same.

Build-System:

Ionic:
  ionic (cli):        4.10.1
  ionic framework:    ionic-angular 3.9.2
  @ionic/app-scripts: 3.1.11

Cordova:
  cordova (cli):      8.1.2 (cordova-lib@8.1.1)
  platforms:          "cordova-android": "8.0.0"

System:
  Android SDK Tools:  26.1.1
  NodeJS:             10.15.3
  npm:                6.4.1
  OS:                 Windows 10

Command:

ionic cordova build android

or

cordova build --release

Error-Details:

Error: Source and destination must not be the same.
    at checkPaths (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\fs-extra\lib\copy-sync\copy-sync.js:185:11)
    at Object.copySync (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\fs-extra\lib\copy-sync\copy-sync.js:25:20)
    at updatePathWithStats (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:103:24)
    at C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:298:19
    at Array.forEach (<anonymous>)
    at Object.mergeAndUpdateDir (C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova-common\src\FileUpdater.js:296:33)
    at updateWww (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\lib\prepare.js:157:17)
    at Api.module.exports.prepare (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\lib\prepare.js:56:19)
    at Api.prepare (C:\Jenkins\workspace\%PROJECTNAME%\platforms\android\cordova\Api.js:177:45)
    at C:\Jenkins\workspace\%PROJECTNAME%\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:105:36

Does anyone facing the same error or has an idea what's wrong?

Additional infos: I always check out the git repository to a empty folder. This means: It's a hard-clean every build. No node_modules and no platform, etc. (rm platform etc. is useless)


Solution

  • The problem is fs-extra checkPaths method of copy operation. There is a check of state.ino (inode) of node fs which is evaluated as number. Bigint is also supported but not enabled. This is the reason that the comparsion can fail. Because max-safe-integer in JavaScript is 53-bit. Maybe also a symlink issue.

    See / Join: https://github.com/jprichardson/node-fs-extra/issues/657

    Why Cordova-Android 8.0.0? Because https://github.com/apache/cordova-common/blob/master/RELEASENOTES.md . fs-extra is new in this version.