Should I be able to set env variables via a dlv-dap remote connection?

Viewed 193
  • Remote OS: Linux/Fedora 33
  • Language: golang 1.16
  • VSCode (Mac): 1.63.2
  • dlv: 1.7.3

Problem: I have used the env and environment keys below but it is not setting the environment variable KUBECONFIG while debugging my go program. I've tried several permutations to set the KUBECONFIG env variable, but to no avail. Any help would be greatly appreciated.

launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  
  "configurations": [
    
    {
      "name": "Connect, build debug and launch",
      "type": "go",
      "request": "launch",
      "debugAdapter": "dlv-dap", // `legacy` by default
      "mode": "auto",
      "program": "${workspaceRoot}",
      "remotePath": "${workspaceRoot}",
      //"port": 2345,
      "debugServer": 2345,
      "host": "127.0.0.1",
      "environment": [ 
          {"name": "GODEBUG", "value": "x509ignoreCN=0"},
          {"name": "KUBECONFIG", "value": "$HOME/.kube/config"}
      ],
      "env": { 
        "KUBECONFIG": "/home/hickersonj/.kube/config" 
      },
      "trace": "verbose",
      "showLog": true,
      "KUBECONFIG": "/home/hickersonj/.kube/config",
      "args": ["${env:KUBECONFIG}:/home/hickersonj/.kube/config"]
      //"args": ["--arg1", "value1", "--arg2", "value2"]
      //"substitutePath": [{"from": "/home/hickersonj/build", "to": "/run/media/hickersonj/fedora_endor/build/"}],
    },
  ]
}

This is the output of dlv-dap debug log output:

    "mode": "debug",
    "program": "/home/hickersonj/build/git/src",
    "args": [
        "KUBECONFIG",
        ":/home/hickersonj/.kube/config"
    ],
    "backend": "default",
    "stackTraceDepth": 50,
    "hideSystemGoroutines": true
}
2021-12-20T19:39:28-08:00 debug layer=dap building from "/home/hickersonj/build/git/src": [go build -o /tmp/__debug_bin827481439 -gcflags all=-N -l /home/hickersonj/build/git/src]
2021-12-20T19:39:28-08:00 debug layer=dap launching binary '/tmp/__debug_bin827481439' with config: {
    "mode": "debug",
    "program": "/home/hickersonj/build/git/src",
    "args": [
        "KUBECONFIG",
        ":/home/hickersonj/.kube/config"
    ],
    "cwd": "/home/hickersonj/build/git/src",
    "output": "/tmp/__debug_bin827481439",
    "dlvCwd": "/home/hickersonj/build/git/src",
    "backend": "default",
    "stackTraceDepth": 50,
    "hideSystemGoroutines": true
}
0 Answers
Related