Skip to content
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

Debugging .NET Core inside a Docker Container from Windows host - Error: Input connection was closed. Aborting the debug session. #1732

Open
lewislabs opened this issue Aug 23, 2017 · 13 comments
Assignees

Comments

@lewislabs
Copy link

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version:
image

C# Extension version:
1.12.1

Docker for Windows version:
Version 17.06.1-ce-win24 (13025)

Steps to reproduce

I have pushed a test repo to GitHub here - https://github.com/lewislabs/test_debug/
Clone this repo and follow the steps for running the app in the readme here

Expected behavior

The application starts up and the breakpoint is hit.

Actual behavior

I get the following output in the debug console and an error popup in VS Code.

Starting: "docker" exec -i test-debug /vsdbg/vsdbg --interpreter=vscode
-> (C) {"command":"initialize","arguments":{"clientID":"vscode","adapterID":"coreclr","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true},"type":"request","seq":1}
Error from pipe program 'docker': Error: Input connection was closed. Aborting the debug session.
<- (ERROR) {"request_seq":2,"success":false,"command":"launch","message":"The pipe program 'docker' exited unexpectedly with code 0.","body":{"error":{"id":1000,"format":"The pipe program 'docker' exited unexpectedly with code 0."}},"seq":1,"type":"response"}
@lewislabs
Copy link
Author

I have tried numerous combinations of pipeProgram and pipeArgs and can't get anything to work!

@lewislabs
Copy link
Author

Changing quoteArgs to false gives me the following output.

Starting: "docker" "exec -i test-debug" "/vsdbg/vsdbg --interpreter=vscode"
-> (C) {"command":"initialize","arguments":{"clientID":"vscode","adapterID":"coreclr","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true},"type":"request","seq":1}
Error from pipe program 'docker': docker: 'exec -i test-debug' is not a docker command.
Error from pipe program 'docker': See 'docker --help'
<- (ERROR) {"request_seq":2,"success":false,"command":"launch","message":"The pipe program 'docker' exited unexpectedly with code 1.","body":{"error":{"id":1000,"format":"The pipe program 'docker' exited unexpectedly with code 1."}},"seq":1,"type":"response"}

@lewislabs
Copy link
Author

Using powershell for the pipeProgram with this launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Docker Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "cwd": "/app",
            "program": "/app/test_debug.dll",
            "sourceFileMap": {
                "/app": "${workspaceRoot}"
            },
            "logging": {
                "engineLogging": true,
                "exceptions": true,
                "moduleLoad": true,
                "programOutput": true
            },
            "pipeTransport": {
                "pipeProgram": "powershell",
                "pipeCwd": "${workspaceRoot}",
                "pipeArgs": [
                    "-c",
                    "docker exec -i test-debug"
                ],
                "debuggerPath": "/vsdbg/vsdbg",
                "quoteArgs": true
            }
        }
    ]
}

I get the same Input connection was closed error

@lewislabs
Copy link
Author

I have realised, almost by pure luck, that I only see this problem when I launch vscode (via code .) from git-bash. If I launch vscode from powershell, the debugger attaches with no problems. This could be worth investigating as it's quite odd and has caused me a lot of wasted time.

@gregg-miskelly
Copy link
Contributor

Glad you found a work around.

As an FYI, what that first error message means is that, inside the container, vsdbg was unable to read from stdin. So this may be a problem with docker rather than this extension. But I will the issue active until someone has the cycles to dig in more and see if there is a C# extension issue.

@WardenGnaw
Copy link
Contributor

@lewislabs Thank you for the test repo! Sadly, I am unable to reproduce the error you get when launching vscode from git-bash.

However, can you provide additional information to help me reproduce this issue?

  • What version if git are you using? This can be done with git --version.
  • Does this occur with the stable version of Docker or the most recent Edge version: 17.07.0-ce-rc4-win25 (13059)?
  • I noticed in the Dockerfile you have FROM microsoft/dotnet:1.1.2-sdk but the host has dotnet version 2.0.0. Does changing it to dotnet:2.0.0-sdk help?

@lewislabs
Copy link
Author

Hi @WardenGnaw

  • git version is git version 2.13.3.windows.1
  • I'm using the stable version of docker. I posted the version number in the issue description.
  • I'll double check if updating the base image version helps and get back to you

@lewislabs
Copy link
Author

Update on the above comment. Using the 2.0.0-sdk and switching the app's runtime to netcoreapp2.0 didn't make any difference. However I think I have actually narrowed this down more to launching vscode from a http://cmder.net/ terminal, not necessarily from git bash. If I use a powershell window in cmder to launch code (code .), debugging doesn't work either. Whereas when launching code from a native powershell terminal, the debugging does work.

@lewislabs
Copy link
Author

Powershell terminal launch command from cmder is

PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''" -new_console:d:"%USERPROFILE%"

@WardenGnaw
Copy link
Contributor

@lewislabs Thanks for the update! I can reproduce this issue with the same error message and will be continuing further investigation.

@WardenGnaw
Copy link
Contributor

It may be an issue with ConEmu. One work around to get VsCode working with Cmder is running set ConEmuANSI=OFF before launching VsCode.

@damtur
Copy link

damtur commented Dec 11, 2017

See Maximus5/ConEmu#1068 as well

Also when running on bash, in cmder setting ConEmuANSI doesn't help

@darkguy2008
Copy link

Same in 2021, any known workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants