Need help to setup PlayCanvas-Sync

I am trying to setup playcanvas-sync, ultimately with TypeScript and hot swapping.

My steps so far:

  • cloned the playcanvas-sync repo and installed the npm package
  • set up the pcconfig file and the values seem to be processed correctly
  • created a pcignore.txt containing only ignore_all_textual_files
    • this is placed in an empty folder (where the PLAYCANVAS_TARGET_DIR points to) and the root in the Editor Assets
  • created a checkpoint containing this pcignore.txt file

Now for any pcwatch or pcsync command I try, I get the following error:

(node:15264) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'total' of undefined
    at LoadAssets.callApi (...\PlayCanvas\src\load-assets.js:39:33)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async LoadAssets.run (...\PlayCanvas\src\load-assets.js:16:7)
    at async AssetStore.populate (...\PlayCanvas\src\asset-store.js:23:26)
    at async GetConfig.setStore (...\PlayCanvas\src\utils\get-config.js:44:25)
    at async GetConfig.run (...\PlayCanvas\src\utils\get-config.js:21:5)
    at async ComputeDiffAll.init (...\PlayCanvas\src\sync-commands\compute-diff-all.js:48:17)
    at async ComputeDiffAll.run (...\PlayCanvas\src\sync-commands\compute-diff-all.js:36:5)
    at async Object.reportDiffAll (...\PlayCanvas\src\sync-commands\sync-utils.js:9:19)
    at async Object.errorIfDifferent (...\PlayCanvas\src\sync-commands\sync-utils.js:113:19)
    at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
    at processPromiseRejections (internal/process/promises.js:247:11)
    at processTicksAndRejections (internal/process/task_queues.js:94:32)
(node:15264) TypeError: Cannot read property 'total' of undefined
    at LoadAssets.callApi (...\PlayCanvas\src\load-assets.js:39:33)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async LoadAssets.run (...\PlayCanvas\src\load-assets.js:16:7)
    at async AssetStore.populate (...\PlayCanvas\src\asset-store.js:23:26)
    at async GetConfig.setStore (...\PlayCanvas\src\utils\get-config.js:44:25)
    at async GetConfig.run (...\PlayCanvas\src\utils\get-config.js:21:5)
    at async ComputeDiffAll.init (...\PlayCanvas\src\sync-commands\compute-diff-all.js:48:17)
    at async ComputeDiffAll.run (...\PlayCanvas\src\sync-commands\compute-diff-all.js:36:5)
    at async Object.reportDiffAll (...\PlayCanvas\src\sync-commands\sync-utils.js:9:19)
    at async Object.errorIfDifferent (...\PlayCanvas\src\sync-commands\sync-utils.js:113:19)
(node:15264) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process w
ith a non-zero exit code.
    at emitDeprecationWarning (internal/process/promises.js:180:11)
    at processPromiseRejections (internal/process/promises.js:249:13)
    at processTicksAndRejections (internal/process/task_queues.js:94:32)

Any help is appreciated :slight_smile:
I would also like to have a look at a project that uses this technology to see the folder structure and how everything is set up.

What files are currently being sync with the online Editor?

The pcignore.txt contains ignore_all_textual_files, so I guess everything that is represented in text form and not binary.
Or do you mean what kind of files we have in the Assets Folder? Scripts (.js), Models (.fbx), Materials, Templates, Fonts (.ttf), …
Or do you mean on my harddrive? There is currently only the cloned playcanvas-sync folder

I just tested the same with a new, empty project (https://playcanvas.com/project/757839) and get the same error.

Regarding the error, it looks like maybe the API key is incorrect as that’s where it’s failing. It be worth double checking your .pcconfig file

Thank you very much, that was it!
I was using the access key from the Editor as described in the babel/typescript-template from whydoidoit and others. Since there is no description about it in the playcanvas-sync readme, I thought they are the same.

I suggest to add a hint to the readme.md, that you need to generate the API token in the account settings :wink:

Added request to the following ticket: https://github.com/playcanvas/playcanvas-sync/issues/7

Thanks :slight_smile: Maybe I can provide the example project myself if everything is running in the end.

Now pcsync is working as it should. However, pcwatch only says Started and stays open (running in Git bash on Windows). When I change a file it does not get uploaded. When I then stop and restart pcwatch, it correctly detects the change with the corresponding error message pointing to pcsync.

I believe there may be some issues with Windows as it was developed on Mac and the file systems may cause some differences.

Might be worth keeping it manual for the moment with push commands.

I reinstalled Node.js / npm with node-gyp and everything, but that didn’t change anything. Any idea where and how I could start to debug this? Otherwise I guess I have no other choice than to push it manually.
What do yo mean with “for the moment”? :wink:

cc @zpaul (author of playcanvas-sync)

If there are problems on Windows, we should fix them given that its the OS with largest userbase :sweat_smile:

1 Like

That’s the interpretation I was hoping for :smile: :+1:

Please double check all paths in your config file, in particular capital letters should match exactly. You should be seeing edit events on windows, so most likely something is wrong with the way you’ve configured the tool. Please review the relevant sections of the readme file.

1 Like

Also pcignore.txt should be in your local target directory, which in turn should be outside of where the tool itself is installed

Sorry I had not updated the initial post, everything is now already setup as you described.
playcanvas-sync is cloned to a different folder than the target dir.
My home directory contains this .pcconfig file:

{
  "PLAYCANVAS_TARGET_DIR": "D:/Documents/Programming/PlayCanvas",
  "PLAYCANVAS_API_KEY": "abcdefghilklmnopqrstuvwxyz123456",
  "PLAYCANVAS_BAD_FILE_REG": "^\\.|~$",
  "PLAYCANVAS_BAD_FOLDER_REG": "\\."
}

In the D:/Documents/Programming/PlayCanvas folder, there are these two files:
pcconfig.json:

{
  "PLAYCANVAS_BRANCH_ID": "abcdef12-3456-789a-bcde-f123456789ab",
  "PLAYCANVAS_PROJECT_ID": 123456
}

And pcignore.txt:

ignore_all_textual_files

After a successfull pcsync pullAll, the target directory now also contains all script files from the project and pcsync pushAll also works.

I believe everything is correct, since pcsync is working fine. I also verified TARGET_DIR, API_KEY, BRANCH_ID, and PROJECT_ID by changing it to another value, in which case pcsync stopped working with a matching error message.
Moreover, pcwatch is starting and detects initial differences during startup, but it does not pick up any file changes while it is running.

Does it work as expected when you use the push/pull commands?

Yes, all pcsync commands work as expected.

1 Like

Cool, that will be something for us to looking into. Could you post the node version you are using as well just incase there’s an issue between node version?

Node.js v14.15.4
npm 6.14.10

Should be the newest ones as I have just reinstalled them.

1 Like