Open rubensa opened 1 year ago
I see.
Quote from Java's document:
envFile - Absolute path to a file containing environment variable definitions.
Do you know why it is absolute path?
BTW
If specified in env instead of envFile, the credentials are uploaded to GitHub along with launch.json. That's risky and inconvenient.
Do you upload .vscode/launch.json
to the repository?
Or why .env is not uplaoded (because it has already been carefully handled?)?
I don't know the reason but, for Java, you can have, in launch.json, something like:
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Application",
"request": "launch",
"mainClass": "org.eu.rubensa.Application",
"projectName": "sample",
"env": {
"ENV_VAR": "value1"
},
"envFile": "${workspaceFolder}/.devcontainer/.env.local"
}
]
}
So it supports variable replacement.
Depending on the project, sometimes the .vscode/launch.json is uploaded to the git repository and sometimes not. But also, sometimes the launch configuration is specified in .devcontainer/devcontainer.json and this is always uploaded to the git repository, like:
{
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Adds default settings.json values into a container/machine specific settings file.
"settings": {
///////////
// Debug //
///////////
// Global debug launch configuration. Should be used as an alternative to 'launch.json' that is shared across workspaces.
"launch": {
"configurations": [
{
"name": "Debug rails server",
"type": "rdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"command": "",
"script": "${workspaceFolder}/bin/rails",
"useBundler": true,
"bundlePath": "${workspaceFolder}/bin/bundle",
"args": [
"server",
"-b",
"0.0.0.0"
],
"useTerminal": true
},
{
"name": "Debug test from current selected test name",
"type": "rdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"command": "",
"script": "${workspaceFolder}/bin/rails",
"useBundler": true,
"bundlePath": "${workspaceFolder}/bin/bundle",
"args": [
"test",
"${file}",
"-n",
"/$(sed 's/ /_/g' <<< '${selectedText}')/"
],
"useTerminal": true
},
{
"name": "Debug tests from current file",
"type": "rdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"command": "",
"script": "${workspaceFolder}/bin/rails",
"useBundler": true,
"bundlePath": "${workspaceFolder}/bin/bundle",
"args": [
"test",
"${file}"
],
"useTerminal": true
},
{
"name": "Debug tests from project",
"type": "rdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"command": "",
"script": "${workspaceFolder}/bin/rails",
"useBundler": true,
"bundlePath": "${workspaceFolder}/bin/bundle",
"args": [
"test"
],
"useTerminal": true
}
]
}
}
}
}
}
And env files are ignored in .gitignore:
.env*
+1 Really need the feature
This is an enhancement request.
When configuring the rdbg in launch.json for launch request, an envFile option will be helpful instead of key in all the env variables.
envFile option has been supported in java, python, nodejs... debuggers.
.env files are commonly used for storing envs esp. for credentials. If specified in env instead of envFile, the credentials are uploaded to GitHub along with launch.json. That's risky and inconvenient.