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.

argsFile and envFile in launch.json

See original GitHub issue

Environment data

dotnet --info output:

.NET-Befehlszeilentools (2.0.2)
 
Product Information:
 Version:            2.0.2
 Commit SHA-1 hash:  a04b4bf512
 
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.2\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version: 1.19.1 C# Extension version: 1.13.1

Feature request

In my launch.json I need to pass sensitive data (like passwords) as arguments (or environment variables). As the launch.json is also committed to Git it’s unwise to place the arguments in there. In NodeJS it is already possible to pass a file containing all the arguments (Microsoft/vscode#14523 and Microsoft/vscode-node-debug2@b3e2e8f3).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
gregg-miskellycommented, Oct 26, 2021

Its closed because @SebastianPfliegel kindly submitted a PR to fix the part that he wanted. I don’t know off hand if VS Code makes the syntax you are suggesting there possible. But you are welcome to open another feature request issue.

2reactions
regul4rj0hncommented, Oct 26, 2021

Sorry to necro but why is this closed? It is still not possible to use args in combination with the envFile. I guess that it would require a 2-step replacement on launch, which doesn’t seem to be implemented (or at least it is not working for me). Is that accurate?

E.g. support the following launch.json :

{
    "version": "0.2.0",
    "configurations": [
        {
          "name": "Launch",
          "type": "go",
          "request": "launch", 
          "mode": "debug",
          "host": "127.0.0.1",
          "program": "${workspaceFolder}/cmd/api",
          "envFile": "${workspaceFolder}/config/.env",
          "args": [
              "-smtp-username", "${env:SMTP_USERNAME}",
              "-smtp-password", "${env:SMTP_PASSWORD}",
              "-auth-url", "${env:AUTH_URL}",
              "-db-dsn", "${env:DB_DSN}",
          ],
          "showLog": true
        }
      ]
}

Expected Result: the args values that point to an env variable get replaced for the correct value whether they reside on the OS or the target envFile.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In VS Code-debugger, how do I use envFile in launch.json for ...
I'm using an .env file to store environment variables that I later call with process.env.. When I looked up the VS Code docs...
Read more >
How to Set up Environment Variables in "launch.json ...
Here is an example, you set the value in the environment block. { // Use IntelliSense to learn about possible attributes.
Read more >
Configuration.md - GitHub
launch.json is used to control the configuration per debug session, and the user setting is shared by the whole workspace or VS Code....
Read more >
Configure launch.json for C/C++ debugging in Visual Studio ...
Visual Studio Code generates a launch.json (under a .vscode folder in your project) with almost all of the required information. To get started...
Read more >
Microsoft/vscode-go - Gitter
When setting up a launch.json file for debugging, when I attempt to reference my projects .env file using the "envFile" attrib, the file...
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