Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep Managed Extensions During Installation #4

Closed
wants to merge 1 commit into from

Conversation

manuth
Copy link
Contributor

@manuth manuth commented Mar 6, 2023

Whenever installExtensions is executed, all existing managed extensions are stripped from the extensions file.
This causes the extensions file, whenever a change happens (through applyChanges or a manual installExtensions invocation from the command palette), to be cleared.

Changes made in this PR fix this issue.

@daiyam
Copy link
Member

daiyam commented Mar 12, 2023

@manuth The extensions in managedExtensions and not in installedExtensions are uninstalled by

await vscode.commands.executeCommand('workbench.extensions.uninstallExtension', extension);

So await fse.writeJSON(extensionsFileName, installedExtensions); is correct.

The uninstall is to remove extensions that aren't managed by the manager anymore.

@manuth
Copy link
Contributor Author

manuth commented Mar 12, 2023

I feel like this might lead to unwanted behaviors.

Imagine I have an entry muhammad-sammy.csharp in my list of extensions to be installed by vsix-manager (vsix-manager.extensions setting, I believe)

What happens to my unserstanding according to the code is the following:

  • When running installExtensions for the first time
    • vsix-manager will notice that muhammad-sammy.csharp isn't installed
    • muhammad-sammy.csharp will be installed and added to installedExtensions
    • The installedExtensions are written to a file extensions.json
  • When running installExtensions a second time (manually, through cron job or during extension activation)
    • vsix-manager will notice that muhammad-sammy.csharp is installed already and skip it without it being added to installedExtensions:
      if(editorExtensions.disabled.includes(extension) || editorExtensions.enabled.includes(extension)) {
      debugChannel?.appendLine('already installed');
      return;
      }
    • With muhammad-sammy.csharp being part of the managedExtensions but not part of installedExtensions, despite the fact that I have it listed in vsix-manager.extensions, the extension will be uninstalled:
      for(const extension in managedExtensions) {
      if(!installedExtensions[extension]) {
      try {
      await vscode.commands.executeCommand('workbench.extensions.uninstallExtension', extension);
      }
      catch {
      }
      }
      }

My original issue, actually is, that when running installExtensions twice, it removes all existing entries from the extensions.json file. But taking the line you have linked in the comment before, it well might even cause that the extensions are both uninstalled and removed from the extensions.json file even if I have them listed in the vsix-manager.extensions setting.

I consider both (the uninstall and the removal from extensions.json) unwanted behaviors.

@daiyam
Copy link
Member

daiyam commented Mar 12, 2023

@manuth You are right there is an issue! I've made #6 to fix it. Can you take a look if it's good for you?

@daiyam daiyam closed this Mar 12, 2023
@manuth
Copy link
Contributor Author

manuth commented Mar 12, 2023

Wow that was fast!
Thanks a ton, I'll give it a go asap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants