skip to Main Content

All of sudden having issue in remote debugging via VS Code using launch.json and remote debugger installed in docker container for .net core project..

The error msg clearly tells about what the issue is, which to me doesn’t make any sense looking at the file comparing to the error pointing to. (the local file being used btw looks exactly same content as master branch of file in this link: remoteProcessPickerScript)

And here is the error I am getting as trying to attach the remote debugging feature of VS Code to the pod via dotnet environment:

kubectl exec -i pod-name -- /bin/sh -c "sh -s" < "c:....vscodeextensionsms-dotnettools.csharp-2.10.28-win32-x64scriptsremoteProcessPickerScript"
stderr: sh: 30: Syntax error: "}" unexpected (expecting "then")
command terminated with exit code 2

2

Answers


  1. I encountered the same issue and in my case, it was related to the line ending of the remoteProcessPickerScript file. I worked around it by opening it in VS Code and changing the line endings from CRLF to LF and re-running.

    However, I’m not sure of the root cause of this issue since the file on the master branch has the proper line endings.

    Login or Signup to reply.
  2. Make sure the remoteProcessPickerScript in your local .vscode directory matches exactly with the one in the master branch of the GitHub repository. Any deviation could cause syntax errors.

    # Compare local script with the remote one
    diff "c:....vscodeextensionsms-dotnettools.csharp-2.10.28-win32-x64scriptsremoteProcessPickerScript" "path/to/downloaded/script/from/github"
    

    The script might be written for a specific shell (like bash), but it is being interpreted by another (like sh). Make sure the script’s shebang line (if any) matches the shell used in the container.

    If you are on a Windows machine, the line endings in the script might be CRLF instead of the Unix-style LF. That can cause issues in Unix environments.

    # Convert CRLF to LF
    dos2unix "c:....vscodeextensionsms-dotnettools.csharp-2.10.28-win32-x64scriptsremoteProcessPickerScript"
    

    Also, if there are special characters in the script, they might need to be escaped differently when passed through kubectl exec.

    For testing, try running the script in the container’s shell directly

    kubectl exec -i pod-name -- /bin/bash -c "cat > script.sh" < "c:....vscodeextensionsms-dotnettools.csharp-2.10.28-win32-x64scriptsremoteProcessPickerScript"
    kubectl exec -it pod-name -- /bin/bash -c "./script.sh"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search