'Is there a way to force sync Visual Studio Code extensions on a seperate machine running a different OS?
Configuration Drift
When I use two systems, I expect both to be synced with the same set of extensions. In my case, the primary system I'm using is at work, and once I load my editor at home I'd expect any uninstalled or added extensions to eventually sync up.
This isn't happening.
My Setup
- I use macOS at work and Windows at home.
- I have the same Visual Studio Code (not insiders) installed.
- I have configured both with settings sync enabled and login.
- I have configured keybindings to be unique per platform.
- My settings.json does seem to sync, but not the extensions installed.
Manual Fix
I'd like to force sync the extensions to get this aligned, but there doesn't seem to be a way to do this in the settings sync UI.
My interim solution was to disable all extensions and then parsed the backed-up json with PowerShell to convert into code install-extension commands. This didn't fix it though as it is still drifting.
My understanding is that key bindings were unique per platform, but extensions should be.
Fixing the Issue Long-Term
Is there anything I should check that prevents extensions from being synced with the built in Visual Studio Code Settings sync.
Note: I'm not using the
Shan.code-settings-syncextension at this time, having migrated over in the last year to the built in sync solution. If I don't figure this out I might consider changing back over.
I'll update this as with my progress figuring it out as a wiki style post if I can resolve through the logs what's actually causing this type of drift.
Solution 1:[1]
I too found that the built-in Vscode settings sync feature has bugs when syncing extensions. In the case of two clean vscode installs on two different machines, none of my extensions synced.
It seems that non existent extensions (perhaps the developer deleted their extension) can cause all extensions to inadvertently be 'blacklisted' in in the file
lastSyncextensions.jsonunder the key"skippedExtensions":[]. You can get to this file via the commandSettings Sync : Open Local Backups Folder. For me, all my extensions were listed to be skipped and thus no extensions were synced on a new install of vscode.Transitory internet errors in syncing e.g. in log
[settingssync] [error] Download: XHR failedalso causes extensions to be blacklisted in"skippedExtensions"in the aforementionedlastSyncextensions.json. This also sometimes causes vscode to broadcast that the extension which could not be download be removed by other machines running vscode (which sync using the same Github account).
Look in the vscode Settings Sync : Show Log and look for the list of skipped extensions.
Once something is blacklisted - the question is how fix the situation.
Solution 1 - Recovering from all extensions being blocked by non-existent extensions
Step 1:
Identify the extensions which no longer exist (search for them in the vscode extensions UI and if they don't appear, then they are the culprits). For me, they happened to be the first few entries in the "skippedExtensions" list. Then add them to "settingsSync.ignoredExtensions" of your settings.json. For my situation, I added the entry:
"settingsSync.ignoredExtensions": [
"patrys.vscode-code-outline",
"gayanhewa.referenceshelper",
"ms-vscode-remote.remote-ssh-explorer"
],
Step 2 (brutal resync):
Now we need to re-sync. Turn off settings sync via the Settings Sync:Show Synced Data / "Synced Machines" r.click on your machine and select "Turn off Settings Sync". This seems to work better than simply logging out of settings sync.
Now click on the normal vscode gear icon (bottom left) and sign in to settings sync. This prompted me like a fresh install, whether to merge, overwrite local etc. This time all the extensions came down OK.
Solution 2 - Recovering from blacklisted extension caused by transient internet errors
Lets say you see some skipped extensions in your sync log (Settings Sync : Show Log):
[2021-12-30 14:05:57.690] [settingssync] [info] Extensions: Updated last synchronized extensions. Skipped: ["sapos.yeoman-ui","tht13.html-preview-vscode","patbenatar.advanced-new-file","alexisvt.flutter-snippets","vscjava.vscode-java-pack","vscjava.vscode-java-dependency","vscjava.vscode-java-test","vscjava.vscode-maven","vscjava.vscode-java-debug","janisdd.vscode-edit-csv","mohd-akram.vscode-html-format","zjhmale.vscode-ag"].
which causes what seems to be a permanent blacklisting of these extensions on your machine in the file lastSyncextensions.json under the key "skippedExtensions". How do you fix this?
You can get to
lastSyncextensions.jsonvia the commandSettings Sync : Open Local Backups Folderand then open the file in vscode itself.
To get those extensions properly installed, I edited lastSyncextensions.json and cleared the list - it now reads as "skippedExtensions":[].
Then I went to each particular extension that was previously skipped, using the vscode UI, and installed it. This should also re-install it on any other vscode machine which might have been affected.
Possibly, a simpler solution 2 (which I haven't tried) is don't bother with editing the file
lastSyncextensions.json- simply do the brutal re-sync described in step 2 of my solution 1 above. Thus hopefully thelastSyncextensions.jsongets regenerated (as well as the problematic"skippedExtensions":entry) and this time pray your internet connection is good and there are no download errors this time.
Solution 2:[2]
Just turning the settings sync off and on did it for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Ehsan Amiri |
