3

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)

Domske
  • 4,795
  • 2
  • 20
  • 35

4 Answers4

2

I don't know if this is the correct answer, but it could be a wrong setting in the cordova build.json (if you have one).

Since you are using Jenkins, maybe you have some wrong settings there like missing dependencies or something like that.

You can also try to remove the platform and add it again to get the latest version and compatibility.

cordova platform remove android
cordova platform add android@8.0.0

You can check if you have an outdated fs-extra (although I don't think that is the problem) and update Ionic.

You can try to restore your node_modules.

I hope one of these steps help.

Mike Quade
  • 231
  • 3
  • 8
2

At first, manually remove this:

node_modules folder

package-lock.json file

platform > android folder

enter image description here

enter image description here

then use this commend:

1 => npm rm -rf node_modules package-lock.json
2 => npm cache clear --force
3 => ionic cordova platform add android@8.0.0
4 => ionic cordova prepare android
5 => ionic cordova run android
MD.Riyaz
  • 412
  • 3
  • 9
2

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.

Domske
  • 4,795
  • 2
  • 20
  • 35
2

In my case it happened while removing/adding android again to make sure that some plugins are updated.

This solution fixed my issue as referenced here

cordova clean android
  • `cordova clean` works for me as well, but I have to do this every time, between doing steps. Is this still the best way to solve it? This is the only solution that seems safe and works. – Tony B Sep 07 '20 at 02:02