Skip to content

Shell command runner does not inherit environment variables from PowerShell #5281

Open

Description

@Omzig

Describe the bug

Environment variables available in the PowerShell process that launches Copilot are not visible to Copilot's shell command runner. This prevents commands and integrations launched by the runner from using user-configured environment variables such as GITHUB_PERSONAL_ACCESS_TOKEN.

Affected version

Copilot CLI 1.0.105

Steps to reproduce the behavior

  1. On Windows, store GITHUB_PERSONAL_ACCESS_TOKEN in the User environment-variable scope.

  2. Open a new PowerShell 7 prompt.

  3. Load the User-scope value into the current process and verify it without printing the secret:

    $env:GITHUB_PERSONAL_ACCESS_TOKEN = [Environment]::GetEnvironmentVariable('GITHUB_PERSONAL_ACCESS_TOKEN', 'User')
    $env:GITHUB_PERSONAL_ACCESS_TOKEN -ne $null

    This returns True.

  4. Launch Copilot CLI from that same PowerShell prompt.

  5. In the Copilot session, run:

    ! $env:GITHUB_PERSONAL_ACCESS_TOKEN -ne $null
    

    This returns False.

  6. The runner reports the following scope state without exposing the secret value:

    Process: False
    User:    True
    Machine: False
    

The behavior reproduces in a newly opened PowerShell prompt and a newly launched Copilot session. No token value was printed or included in this report.

Expected behavior

The shell command runner should inherit the environment of the Copilot process that was launched from PowerShell, or the behavior should be clearly documented if credential variables are intentionally filtered.

Additional context

  • Operating system: Windows
  • Shell: PowerShell 7
  • The runner and launcher are running under the same Windows account; account/domain details are intentionally omitted.
  • The issue appears specific to the Copilot command-runner process boundary. It may be intentional credential sanitization, but this is not documented and prevents expected environment-based authentication for child commands.

Activity

  1. Omzig commented on Oct 28, 2026

    @Omzig
    Author

    Workaround on every new session shell call:

    $env:GITHUB_PERSONAL_ACCESS_TOKEN = [Environment]::GetEnvironmentVariable('GITHUB_PERSONAL_ACCESS_TOKEN', 'User')

  2. added
    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal
    area:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior
    and removed on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminalarea:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions