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 silently drops errors logged by pipe program to stdout

See original GitHub issue

Environment data

dotnet --info output:


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

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version: Version 1.18.0 (1.18.0) C# Extension version: 1.13.0

Goal

I would like to create a .Net Core application based on multiple microservices. The services should be developed and published with Docker. The development process should be as comfortable as possible, without waiting minutes for Docker to build images and run the .Net app. Therefore, I’m mounting my source code inside the docker container and started the dotnet watch run -p /app command in order to restart the server on code changes. That’s working well. Only downside is that I have to put my source code into a subfolder to not mount bin/ and obj/ folder, because the container is building the app and not my host machine. If you got improvements or ideas, please let me know! I’m still learning Docker and .Net Core, therefore I’m happy to get feedback!

Now I would like to debug my code inside the docker container.

Steps to reproduce

Dockerfile

FROM microsoft/dotnet:sdk

ENV ASPNETCORE_URLS http://*:5000
ENV ASPNETCORE_ENVIRONMENT Development
EXPOSE 5000
WORKDIR /app

# prereq
RUN apt-get update && \
    && rm -rf /var/lib/apt/lists/* \
    apt-get install -y--no-install-recommends unzip curl
# install vs debug to debug inside this container
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg

# copy csproj and restore as distinct layers
COPY *.csproj .
RUN ["dotnet", "restore"]

ENTRYPOINT ["dotnet", "watch", "run", "-p /app"]

Compose

version: '3'

services:
  cablereelservice-db:
    image: postgres:latest
    environment:
      POSTGRES_USER: "cablereel"
      POSTGRES_PASSWORD: "secret"
    ports:
      - "6001:5432"
    volumes:
      - db-data-cablereel:/var/lib/postgresql/data

  cablereelservice:
    build:
      context: ./../../CargoSharp.Services.CableReel
      dockerfile: local.df
    ports:
      - "5001:5000"
    volumes:
      - ./../../CargoSharp.Services.CableReel/src:/app/src
    depends_on:
      - cablereelservice-db

volumes:
  db-data-cablereel:

launch.json

{
   "version": "0.2.0",
   "configurations": [
    {
        "name": "CableReelService (Attatch)",
        "type": "coreclr",
        "request": "attach",
        "processId": "${command:pickRemoteProcess}",
        "pipeTransport": {
            "pipeProgram": "docker",
            "pipeArgs": [ "exec", "-i", "local_cablereelservice_1" ],
            "debuggerPath": "~/vsdbg/vsdbg",
            "pipeCwd": "${workspaceRoot}",
            "quoteArgs": false
        },
        "sourceFileMap": {
            "/app/bin/Debug/netcoreapp2.0": "${workspaceRoot}/CargoSharp.Services.CableReel"
        }
    }
    ]
}

Project Strutcure

All microservices are hosted inside one repo. They should follow a structure similar the following one:

FirstMicroService
|
| _ bin/
| _ obj/
| _ src/
|      | _ models/
|      | _ services/
|      | _ modules/
|      | _ appsettings.json
|      | _ Startup.cs
|      | _ Program.cs
| _ .dockerignore
| _ FirstMicroService.csproj
| _ web.config

Expected behavior

  1. Start all containers
docker-compose up
  1. Set a breakpoint and debug code of one specific container.

Actual behavior

Output:

Error: Starting: "docker" exec -i local_cablereelservice_1 ~/vsdbg/vsdbg --interpreter=vscode

and:

The pipe program 'docker' exited unexpectedly with code 126.

I have no clue what is going wrong and I don’t get any valuable from the output and error message. I’ve tried selecting every process from the vs picker (${command:pickRemoteProcess}) without success. Any ideas or suggestions? Thanks in advance!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
gregg-miskellycommented, Nov 15, 2017

Currently the pipe transport handler will do a good job of reporting errors logged to stderr, but if the pipe program logs errors of stdout we silently drop them on the floor. I will retitle this to investigate doing a better job here.

0reactions
gregg-miskellycommented, Feb 3, 2018

We are aiming to release 1.14 pretty soon. But you can try it now if you like – https://github.com/OmniSharp/omnisharp-vscode/wiki/Installing-Beta-Releases

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid a Broken Pipe error when printing a large ...
This causes print to fail, internally it writes to sys.stdout , now closed. You can simply catch the IOError and exit silently: try:...
Read more >
How we use logging - Tit Petric
Split the log destination based on message severity (debug output, info, errors). For people somewhat familiar with linux, you might asume that ...
Read more >
How and when to use stdout and stderr? - Julien Harbulot
How to use stderr in python? Displaying runtime information, debug, warnings and errors is done in python through the standard logging module.
Read more >
Silencing the Output of a Bash Command | Baeldung on Linux
In this quick tutorial, we'll focus on how to silence the output of a ... Two of these FDs are Standard output (stdout)...
Read more >
How can I make ffmpeg be quieter/less verbose? - Super User
Should make it so only serious errors are logged, in theory ... Show everything, including debugging information. ... You can pipe stderr through...
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