Skip to content

Fix Dev Container / Codespaces support for non-default usernames #9538

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 27, 2025

This PR fixes an issue where Aspire would only work with the default vscode username in Dev Containers and GitHub Codespaces environments. When using a different username in .devcontainer/devcontainer.json configuration (e.g., "remoteUser": "root"), the application would fail with a System.IO.DirectoryNotFoundException because it was looking for configuration files in a hardcoded /home/vscode/ path.

Changes

  • Replace hardcoded /home/vscode/ paths with path segments relative to the user's home directory
  • Add a method to dynamically get the user's home directory using Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
  • Update path construction in GetSettingsPaths() to use the actual user's home directory
  • Add detailed comments explaining the approach

Before

private const string CodespaceSettingsPath = "/home/vscode/.vscode-remote/data/Machine/settings.json";
private const string VSCodeServerPath = "/home/vscode/.vscode-server";
private const string VSCodeInsidersServerPath = "/home/vscode/.vscode-server-insiders";

After

private const string VscodeRemotePathSegment = ".vscode-remote/data/Machine/settings.json";
private const string VscodeServerPathSegment = ".vscode-server";
private const string VscodeInsidersServerPathSegment = ".vscode-server-insiders";

private static string GetUserHomeDirectory() => 
    Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

This ensures Aspire will work properly regardless of the username specified in the Dev Container or Codespace configuration.

Fixes #9533.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 0t3vsblobprodcus362.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • 7devsblobprodcus323.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • 7k6vsblobprodcus337.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • dlbvsblobprodcus316.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • h6tvsblobprodcus346.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • i1qvsblobprodcus353.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • imzvsblobprodcus368.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • jd4vsblobprodcus366.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • kh4vsblobprodcus325.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • ofvvsblobprodcus315.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • p2ovsblobprodcus312.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • pe4vsblobprodcus351.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)
  • x3yvsblobprodcus370.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Dev Container / Codespaces Support does only work with vscode user Fix Dev Container / Codespaces support for non-default usernames May 27, 2025
@Copilot Copilot AI requested a review from mitchdenny May 27, 2025 23:10
Copilot finished work on behalf of mitchdenny May 27, 2025 23:10
@mitchdenny
Copy link
Member

I've verified that this appears to be working within a codespace for the existing vscode user (so existing functionality hasn't broken). Now looking to verify with a devcontainer locally with non-vscode user.

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.

Dev Container / Codespaces Support does only work with vscode user
2 participants