microsoft / microsoft/vscode

Agent plugins: Install Plugin From Source deletes plugins installed from a marketplace on the same repository

Open
#336,777 0 comments 0 reactions 1 assignee Assigned to @pwang347 View on GitHub
chat new release
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

Does this issue occur when all extensions are disabled?: Yes

- VS Code Version: 1.138.0 (stable, commit 7debcd0e2acdea1c52de81bf9ee1620444407dda). The code involved is unchanged on `main` at 0dbdacd.
- OS Version: Windows 11 (10.0.26200)

When a marketplace is configured with a ref, running "Chat: Install Plugin From Source" on the same repository without a ref deletes the marketplace clone. Any plugin installed from that marketplace loses its files. The default value of `chat.plugins.marketplaces` includes `github/awesome-copilot#marketplace`, so a default setup reproduces the problem.

Steps to Reproduce:

1. With default settings, open the Extensions view, search `@agentPlugins`, and install `arch` from `github/awesome-copilot`. Accept the trust prompt.
2. Check that `/github.com/github/awesome-copilot/ref_marketplace/plugins/arch` exists and that `installed.json` lists `arch`.
3. Run "Chat: Install Plugin From Source", enter `github/awesome-copilot`, and accept the trust prompt.

`` is `%USERPROFILE%\.vscode\agent-plugins`. I used a portable install, where the folder is `data\agent-plugins`.

Result:

- The input box shows "No plugins found in 'github/awesome-copilot'. This does not appear to be a valid plugin marketplace." The `main` branch of that repository has a `.github/plugin/marketplace.json` that lists 162 plugins.
- The `/github.com/github/awesome-copilot` folder is deleted, including the `ref_marketplace` clone.
- `installed.json` still lists `arch`, and the plugin no longer loads.

Renderer log at trace level:

```
10:02:20.772 [debug] [PluginMarketplaceService] No marketplace.json found in github/awesome-copilot
10:02:20.775 [debug] [PluginMarketplaceService] No single-plugin manifest found in github/awesome-copilot
10:02:21.372 [info] [github] Removed plugin cache: file:////github.com/github/awesome-copilot
10:02:21.580 [debug] [MarketplaceAgentPluginDiscovery] Could not resolve installed plugin: file:////github.com/github/awesome-copilot/ref_marketplace/plugins/arch
```

I reproduced this twice, the second time from an empty portable profile. Running step 3 again right after the failure works: VS Code clones `main` and lists the plugins. Only the failing run started with the `ref_marketplace` clone on disk.

Expected: the source install clones the repository and leaves the marketplace clone in place. A failed install removes only the files that install created.

Likely cause, from reading the source on `main`:

The marketplace clone for `owner/repo#ref` goes in `github.com///ref_`. `_doInstallFromSource` builds its source descriptor without a ref, so `GitHubPluginSource._getRepoDir` returns the parent folder, `github.com//`. Because that folder already exists, `AbstractGitPluginSource.ensure` skips the clone. The folder root has no manifest, so `_doInstallFromSource` calls `cleanupPluginSource`, which deletes the folder recursively.

The shared-cache check in `cleanupPluginSource` does not run on this path, because the call passes no `otherInstalledDescriptors`. The check also compares paths for equality, so it would not detect a clone nested below the target. `GitUrlPluginSource` uses the same folder layout, so a git URL marketplace with a ref, such as an Azure DevOps remote, has the same problem.

Separately, `_doInstallFromSource` parses a `#ref` in the input but drops the ref from the source descriptor, so a source install always clones the default branch.

Some ways to fix the collision:

- Give ref-less source clones a folder that cannot contain a `ref_` folder, such as a `default` segment.
- Check that an existing folder is a git work tree before skipping the clone.
- On failure, delete the folder only when the current install created it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.