Skip to content

Cannot download roslyn copilot package when http_proxy env var is set to empty #8578

@jonathanou

Description

@jonathanou

Environment data

dotnet --info output:

vscode ➜ /workspaces/dotnet $ dotnet --info
.NET SDK:
 Version:           9.0.302
 Commit:            bb2550b9af
 Workload version:  9.0.300-manifests.fadeff71
 MSBuild version:   17.14.13+65391c53b

Runtime Environment:
 OS Name:     debian
 OS Version:  12
 OS Platform: Linux
 RID:         linux-arm64
 Base Path:   /usr/share/dotnet/sdk/9.0.302/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.7
  Architecture: arm64
  Commit:       3c298d9f00

.NET SDKs installed:
  9.0.302 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.7 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.7 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

VS Code version:

Version: 1.103.2 (Universal)
Commit: 6f17636121051a53c88d3e605c491d22af2ba755
Date: 2025-08-20T16:45:34.255Z
Electron: 37.2.3
ElectronBuildId: 12035395
Chromium: 138.0.7204.100
Node.js: 22.17.0
V8: 13.8.500258-electron.0
OS: Darwin arm64 24.6.0

C# Extension version: 2.90.51

C# logs

C# output window contents:

2025-09-01 03:52:45.112 [trace] Activating C# Extension
2025-09-01 03:52:45.112 [info] Installing C# dependencies...
2025-09-01 03:52:45.112 [info] 

2025-09-01 03:52:45.112 [info] Platform: linux, arm64, name=debian, version=12

2025-09-01 03:52:45.112 [info] 

2025-09-01 03:52:45.112 [info] Downloading package 'Language server for Roslyn Copilot integration' 
2025-09-01 03:52:45.112 [info] Failed at stage: downloadPackage

2025-09-01 03:52:45.112 [info] TypeError: Invalid URL

2025-09-01 03:52:45.112 [info] 

2025-09-01 03:52:45.112 [debug] Extension vscode.configuration-editing does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.css-language-features does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.debug-auto-launch does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.debug-server-ready does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.emmet does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.extension-editing does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.git does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.git-base does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.github does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.grunt does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.gulp does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.html-language-features does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.ipynb does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.jake does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.json-language-features does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.markdown-language-features does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.markdown-math does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.merge-conflict does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension ms-vscode.js-debug does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension ms-vscode.vscode-js-profile-table does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.npm does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.php-language-features does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.references-view does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.search-result does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.terminal-suggest does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.tunnel-forwarding does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension vscode.typescript-language-features does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension dbaeumer.vscode-eslint does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension GitHub.copilot does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension GitHub.copilot-chat does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension GitHub.vscode-pull-request-github does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension ms-dotnettools.csdevkit does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension ms-dotnettools.csharp does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [debug] Extension ms-dotnettools.vscode-dotnet-runtime does not contribute csharpExtensionLoadPaths
2025-09-01 03:52:45.112 [trace] C# Extension activated in 33.479ms.
2025-09-01 03:52:45.916 [info] Locating .NET runtime version 9.0.1
2025-09-01 03:52:45.950 [info] Dotnet path: /usr/share/dotnet/dotnet
2025-09-01 03:52:45.950 [info] Activating C# + C# Dev Kit...
2025-09-01 03:52:45.972 [error] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Component DLL not found: /home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/.roslynCopilot/Microsoft.VisualStudio.Copilot.Roslyn.LanguageServer.dll
    at i0 (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/dist/extension.js:1203:9455)
    at Function.setupDevKitEnvironment (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/dist/extension.js:1208:27174)
    at Function.startServer (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/dist/extension.js:1208:21528)
    at l (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/dist/extension.js:1208:15488)
    at Q3.createConnection (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/dist/extension.js:58:11280)
    at Q3.start (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/dist/extension.js:58:1231)
    at Function.initializeAsync (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/dist/extension.js:1208:16003)
    at oje (/home/vscode/.vscode-server/extensions/ms-dotnettools.csharp-2.90.51-linux-arm64/dist/extension.js:1208:38465)

Steps to reproduce

  1. Create a new dev container with the following devcontainer.json:
{
    "name": "C# (.NET)",
    "image": "mcr.microsoft.com/devcontainers/dotnet:1-9.0-bookworm",

    "remoteEnv": {
        "HTTP_PROXY": "${localEnv:HTTP_PROXY}",
        "HTTPS_PROXY": "${localEnv:HTTPS_PROXY}"
    },

    "customizations": {
        "vscode": {
	    "extensions": [
        	"ms-dotnettools.csdevkit"
            ]
        }
    }
}
  1. Make sure your host system does not have HTTP_PROXY/HTTPS_PROXY set (i.e. environment variables needs to be unset).
  2. Reopen in dev container and wait for extensions to be installed.
  3. Create and open a new helloworld.cs file to activate the C# extension.

Expected behavior

C# extension activates properly.

Actual behavior

C# extension fails to activate due to Invalid URL when trying to download the Roslyn Copilot Language Server (see log above for full details):

2025-09-01 03:52:45.112 [info] Downloading package 'Language server for Roslyn Copilot integration' 
2025-09-01 03:52:45.112 [info] Failed at stage: downloadPackage

2025-09-01 03:52:45.112 [info] TypeError: Invalid URL

Additional context

I have tested that if I don't set HTTP_PROXY in the dev container, or if HTTP_PROXY is set to a valid proxy url, C# extension downloads the package and activates correctly.

Looking at the code, I believe the issue is how the system proxy url is obtained:

function getSystemProxyURL(requestURL: Url): string | undefined {
    if (requestURL.protocol === 'http:') {
        return process.env.HTTP_PROXY ?? process.env.http_proxy;
    } else if (requestURL.protocol === 'https:') {
        return process.env.HTTPS_PROXY ?? process.env.https_proxy ?? process.env.HTTP_PROXY ?? process.env.http_proxy;
    }

    return undefined;
}

export function getProxyAgent(requestURL: Url, proxy: string, strictSSL: boolean): Agent | undefined {
    const proxyURL = proxy.length > 0 ? proxy : getSystemProxyURL(requestURL);

    if (proxyURL === undefined) {
        return undefined;
    }

    const proxyEndpoint = new URL(proxyURL);

    ...
}

The code checks if HTTP_PROXY is defined, and if not, returns undefined for getProxyAgent. But in my case, my HTTP_PROXY is defined, but is an empty string. The code ends up passing an empty string to new URL(proxyURL), most likely causing the Invalid URL error shown in the logs.

Why HTTP_PROXY may be set to empty

Certain team members on my team rely on proxy servers to get around restrictive network environments, and thus have HTTP_PROXY/HTTPS_PROXY set on their machines. To ensure the dev container can properly run apt-get and other commands that require network access, we want to propagate the host's environment variables to the dev container via removeEnv configuration in devcontainer.json.

The problem is not all team members need to use proxy servers, and thus in those cases HTTP_PROXY will be unset in the host system, causing the dev container to set HTTP_PROXY to empty.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions