question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugger reports errors when running script with improperly encoded characters

See original GitHub issue

System Details

  • Operating system name and version:
  • VS Code version: 1.13.0
  • PowerShell extension version: 1.3.2
  • Output from $PSVersionTable:
Name                           Value                                                                                                                                
----                           -----                                                                                                                                
PSVersion                      5.1.15063.296                                                                                                                        
PSEdition                      Desktop                                                                                                                              
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                              
BuildVersion                   10.0.15063.296                                                                                                                       
CLRVersion                     4.0.30319.42000                                                                                                                      
WSManStackVersion              3.0                                                                                                                                  
PSRemotingProtocolVersion      2.3                                                                                                                                  
SerializationVersion           1.1.0.1                                                                                                                              

Copy / paste the below commands into the PowerShell Integrated Terminal, and paste the output here

code -v $pseditor.EditorServicesVersion code --list-extensions --show-versions $PSVersionTable

PS C:\gd\Documents\s\docker\tools\vstsagent> code -v
1.13.0
376c52b955428d205459bea6619fc161fc8faacf
PS C:\gd\Documents\s\docker\tools\vstsagent> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      3      2      0


PS C:\gd\Documents\s\docker\tools\vstsagent> code --list-extensions --show-versions
DotJoshJohnson.xml@1.8.0
mkloubert.vs-deploy@9.25.0
ms-vscode.csharp@1.10.0
ms-vscode.PowerShell@1.3.2
PeterJausovec.vscode-docker@0.0.16

Issue Description

Configuration below will throw powershell engine off and will report errors below

Configuration test {
    Script DockerConfigFile {
        TestScript = {
            return $true;
        }
        GetScript = {
          
            return {@{configValue = "dd"}
            }
        }
        SetScript = {
            $dockerConfig | Add-Member –MemberType NoteProperty –Name graph –Value $graphLocation
               
        }
    }
}
Test

Errors reported during run

At C:\gd\Documents\s\docker\tools\vstsagent\test.ps1:12 char:82
+ ... ember –MemberTypeNoteProperty –Name graph –Value $graphLocation
+                                                     ~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: ".

At C:\gd\Documents\s\docker\tools\vstsagent\test.ps1:11 char:21
+         SetScript = {
+                     ~
Missing closing '}' in statement block or type definition.

At C:\gd\Documents\s\docker\tools\vstsagent\test.ps1:17 char:5
+ Test
+     ~
There is an incomplete property assignment block in the instance definition.

At C:\gd\Documents\s\docker\tools\vstsagent\test.ps1:1 char:20
+ Configuration test {
+                    ~
Missing closing '}' in statement block or type definition.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Eickhelcommented, Jan 30, 2018

Great work @tylerl0706! thanks for confirm the bug… I guess it’s time to move to PS Core 😉

1reaction
TylerLeonhardtcommented, Jan 29, 2018

Ah. I’ve got a repro!

It’s only on Windows PowerShell and this is, in fact, a Windows PowerShell bug. Here’s why:

let’s say we have @Eickhel’s example:

function Convert-Exceptions {
    param ([String]$src = [String]::Empty)
    $src -replace "el medano", "el médano"
}

Convert-Exceptions("el medano")

With the PowerShell ISE, when you have an untitled file and hit F5, it does the same thing as if you selected all the text and hit F8 (aka ctrl-A, F8). image

If you save the file to something, like test.ps1 it runs the actual file like so: image

Notice the bad formatting!

VSCode runs the file that you are F5’ing as well:

PS C:\Users\tylerleonhardt\Desktop> c:\Users\tylerleonhardt\Desktop\test.ps1

If we run that exact line in Windows PowerShell as well we get the same wrong formatting: image

If we try this is PowerShell Core 6, the bug was fixed and the output is what we expect: image

Moral of the story, this is a bug in Windows PowerShell and not the PowerShell extension for VSCode.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect utf-8 encoding in the console after executing Run or ...
Executing Run or Debug commands on a Python file with characters encoded in utf-8 incorrectly displays said characters in the output console window....
Read more >
VSCode debugger having issues with character encoding
This problem can be fixed by running -exec set charset UTF-8 from the debug console while debugging but it is only a temporary...
Read more >
21. Error Handling and Debugging - Practical mod_perl [Book]
These messages indicate that Perl thinks there is a problem with your code, but they do not prevent the code from running. Errors...
Read more >
Error Messages - Lauterbach
Error Messages Related to Debug Hardware and Software ... escape characters are used for suppressing of name character syntax check.
Read more >
A Definitive Guide to Handling Errors in JavaScript - Kinsta
Here is how you can define an error in JavaScript: const wrongTypeError = TypeError("Wrong type found, expected character").
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found