# Using the Microsoft vs Code Marketplace in Code-Server


To point `code-server` at the Microsoft VS Code Marketplace, set the `EXTENSIONS_GALLERY` environment variable. The `systemd --user` override looks like this:

```ini
[Service]
Environment='EXTENSIONS_GALLERY={"serviceUrl":"https://marketplace.visualstudio.com/_apis/public/gallery","itemUrl":"https://marketplace.visualstudio.com/items","resourceUrlTemplate":"https://%%7Bpublisher%%7D.vscode-unpkg.net/%%7Bpublisher%%7D/%%7Bname%%7D/%%7Bversion%%7D/%%7Bpath%%7D","controlUrl":"","recommendationsUrl":""}'
```

If your service is also the user service `code-server.service`, run:

```bash
systemctl --user edit code-server.service
```

Paste the override above, then reload and restart:

```bash
systemctl --user daemon-reload
systemctl --user restart code-server.service
```

You can verify whether the environment variable was injected correctly with:

```bash
systemctl --user show code-server.service -p Environment
```

If it worked, you should see a valid JSON string there, not a broken one.

## The Two Pitfalls

### I. `%` must be written as `%%`

The `resourceUrlTemplate` contains `%7B` and `%7D`.

But inside a `systemd` unit, `%` is treated as a specifier. If you write `%7Bpublisher%7D` directly, the service will log an error like this:

```text
Failed to resolve specifiers ... ignoring: Invalid slot
```

So every `%` in that URL must be escaped as `%%`.

### II. The whole value must be quoted once more

If you write this directly:

```ini
Environment=EXTENSIONS_GALLERY={"serviceUrl":"..."}
```

`systemd` will strip the JSON quotes before passing it to the process. The result is invalid JSON, and `code-server` may return HTTP 500.

So it needs to be written like this instead:

```ini
Environment='EXTENSIONS_GALLERY={"serviceUrl":"..."}'
```

In other words, wrap the whole `KEY=VALUE` in one extra layer of quotes.

## One More Note

I run the user service, and the file I changed was:

```text
~/.config/systemd/user/code-server.service.d/override.conf
```

not the system-level `code-server@.service`.

After reloading and restarting, the page loaded normally and the Microsoft marketplace worked.


---

> Author: Nite  
> URL: https://www.nite07.com/en/posts/code-server-microsoft-marketplace/  

