Skip to content

PowerShell Terminal broken: Unexpected token: ']' #7

Open

Description

@olconstant

The Zoo Code terminal integration causes issues on PyCharm Terminal:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved. 

Loading personal and system profiles took 11080ms. 
At C:\Users\%user%\.run-vs-agent-shell-integration\vscode-powershell\profile.ps1:89 char:21
+    $Result += "]633;A" + $bell
+
Unexpected token ']' in expression of statement. 
At C:\Users\%user%\.run-vs-agent-shell-integration\vscode-powershell\profile.ps1:144 char:22
+    $Result += $esc + "]633;C" + $bell
+
Unexpected token ']' in expression of statement. 
    + CategoryInfo              : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

It runs on latest Zoo Code version (3.82.1) on PyCharm. It breaks Python environment activation (conda) on PyCharm Terminal. The issue disappear when the Zoo Code plugin is disabled.

Activity

  1. olconstant commented on Sep 25, 2026

    @olconstant
    Author

    Any plan to fix this bug? I'm stuck with Cline because of this bug. Having a working Terminal on IDE is important. Thanks.

  2. changed the title [-]PowerShell terminal is reporting ] as unexpected[/-] [+]PowerShell Terminal broken: Unexpected token: ']'[/+] on Sep 25, 2026
  3. aGitForEveryone commented on Oct 5, 2026

    @aGitForEveryone

    I opened an issue on this on the original Zoo Code repo: Zoo-Code-Org/Zoo-Code#1752. Some initial investigation was done on the issue. Hope that it gets translated into a bugfix soon.

  4. aGitForEveryone commented on Oct 22, 2026

    @aGitForEveryone

    I want to highlight this issue again. In PR #10 step 1 was taken to fix compatibility issues, the emojis that were causing an issue are removed. thanks!

    However, a second part is still not fixed: running PyCharms activation scripts. The response in Zoo-Code-Org/Zoo-Code#1752 suggests as a solution to add in ZooCode's profile.ps1:

    $pyCharmScript = $env:ORIGINAL_POWERSHELL_SCRIPT
    if ($pyCharmScript -and (Test-Path -LiteralPath $pyCharmScript)) {
        . $pyCharmScript
    }
    $env:ORIGINAL_POWERSHELL_SCRIPT = $null
    

    I tried that on my own system. I added the snippet under the section # Load user's original PowerShell profile if shell integration was injected. So the code becomes:

    # Load user's original PowerShell profile if shell integration was injected
    if ($env:VSCODE_INJECTION -eq "1") {
    	# Source user's original profile if it exists
    	$UserProfile = $PROFILE.CurrentUserCurrentHost
    	if (Test-Path $UserProfile) {
    		. $UserProfile
    	}
    	$env:VSCODE_INJECTION = $null
    }
    
    $pyCharmScript = $env:ORIGINAL_POWERSHELL_SCRIPT
    if ($pyCharmScript -and (Test-Path -LiteralPath $pyCharmScript)) {
        . $pyCharmScript
    }
    $env:ORIGINAL_POWERSHELL_SCRIPT = $null
    
    $Global:__VSCodeOriginalPrompt = $function:Prompt
    $Global:__LastHistoryId = -1
    $Global:__VSCodeIsInExecution = $false
    

    On my system this change reactivates the virtual environment, i.e. solves the issue. You can try this in a live PyCharm window with the ZooCode plugin enabled. In the default state, the virtual environment is not activated. Next, open C:\Users\<user>\.run-vs-agent-shell-integrations\vscode-powershell\profile.ps1, replace the code as above. After saving the file, open a new PowerShell instance in PyCharm. You should see that the active interpreter is now correctly activated.

    Can this extra section be added to the profile.ps1 script?

  5. aGitForEveryone commented on Oct 22, 2026

    @aGitForEveryone

    To already make a headstart in solving this issue, I made a PR: #11.

    Note that I only verified this change in PyCharm as that is the only JetBrains tool that is use. Do you have tests to check other JetBrains IDEs?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions