{"record":{"id":"cbe1ea964aa212b0","repo":"laurent22/joplin","slug":"cannot-initialise-synchroniser","errorCode":null,"errorMessage":"Cannot initialise synchroniser.","messagePattern":"Cannot initialise synchroniser\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-sync.ts","lineNumber":193,"sourceCode":"\t\t\t\tapp().gui().showConsole();\n\t\t\t\tapp().gui().maximizeConsole();\n\n\t\t\t\tconst authDone = await this.doAuth();\n\t\t\t\tif (!authDone) return cleanUp();\n\t\t\t}\n\n\t\t\tconst sync = await syncTarget.synchronizer();\n\n\t\t\tconst options: SyncStartOptions = {\n\t\t\t\tonProgress: (report) => {\n\t\t\t\t\tconst lines = Synchronizer.reportToLines(report);\n\t\t\t\t\tif (lines.length) cliUtils.redraw(lines.join(' '));\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tthis.stdout(_('Synchronisation target: %s (%s)', Setting.enumOptionLabel('sync.target', this.syncTargetId_), this.syncTargetId_));\n\n\t\t\tif (!sync) throw new Error(_('Cannot initialise synchroniser.'));\n\n\t\t\tif (args.options.upgrade) {\n\t\t\t\tlet migrationError = null;\n\n\t\t\t\ttry {\n\t\t\t\t\tconst migrationHandler = new MigrationHandler(\n\t\t\t\t\t\tsync.api(),\n\t\t\t\t\t\treg.db(),\n\t\t\t\t\t\tsync.lockHandler(),\n\t\t\t\t\t\tappTypeToLockType(Setting.value('appType')),\n\t\t\t\t\t\tSetting.value('clientId'),\n\t\t\t\t\t);\n\n\t\t\t\t\tmigrationHandler.setLogger(cliUtils.stdoutLogger(this.stdout.bind(this)));\n\n\t\t\t\t\tawait migrationHandler.upgrade();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tmigrationError = error;","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-sync.ts#L175-L211","documentation":"Thrown by `sync` when `syncTarget.synchronizer()` returns a falsy value, meaning the sync target could not build a working Synchronizer instance. By this point authentication has already succeeded, so the failure is in target setup — typically a missing/invalid auth token, unsupported sync target, or an API client construction error that the target swallowed and returned null for.","triggerScenarios":"Configuring `sync.target` to a value whose SyncTargetRegistry entry cannot produce a synchronizer (e.g. missing OneDrive/Dropbox auth JSON even though `isAuthenticated` passed), or pointing at an incompatible/unsupported target id. Also possible if the target's api() threw internally and the implementation returned null.","commonSituations":"First-time sync setup where credentials were partially provided; switching `sync.target` without re-authenticating; a corrupted `sync.<id>.auth` setting string; using a sync target plugin that failed to load.","solutions":["Re-run authentication for the target: `:sync` will trigger `doAuth()` if `isAuthenticated` is false — but if it returns true yet synchronizer() is null, force re-auth by clearing `sync.<id>.auth`.","Verify `sync.target` points to a supported id (3=OneDrive, 5=Dropbox, 7=WebDAV, 9=File system, 10=Joplin Cloud, etc.).","Check the log output for the underlying api() error that caused synchronizer() to return null.","If using Joplin Server, confirm `sync.10.path` is reachable and the API token/credentials are valid."],"exampleFix":"// before\nif (!sync) throw new Error(_('Cannot initialise synchroniser.'));\n\n// after - surface the underlying cause if available\nif (!sync) throw new Error(_('Cannot initialise synchroniser for target %s (%s). Check sync.%s.auth and re-authenticate.', Setting.enumOptionLabel('sync.target', this.syncTargetId_), this.syncTargetId_, this.syncTargetId_));","handlingStrategy":"validation","validationCode":"const sync = await syncTarget.synchronizer();\nif (!sync) {\n\tthrow new Error(`Synchroniser for target ${Setting.value('sync.target')} is null. Verify auth and sync.target config.`);\n}","typeGuard":"null","tryCatchPattern":"try {\n\tawait sync();\n} catch (e) {\n\tif (/Cannot initialise synchroniser/.test(e.message)) { /* clear sync.<id>.auth, re-run doAuth, retry */ }\n\telse throw e;\n}","preventionTips":["Confirm `sync.target` is set to a supported id before invoking sync.","Re-authenticate the target if synchronizer() returns null.","Inspect logs for the underlying api() error that produced null."],"tags":["sync","synchronizer","config","auth","cli","sync-target"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}