Skip to content

Commit

Permalink
Auto merge of rust-lang#17295 - 0xJonas:fix_passing_env_vars_to_cppto…
Browse files Browse the repository at this point in the history
…ols, r=Veykril

Use correct format for setting environment variables when debugging with cpptools

The RA VSCode extension uses an incorrect format for the environment variables in the `launch.json` when debugging with the C/C++ Extension. This extension uses a different format than CodeLLDB or NativeDebug, which means that the environment variables are not actually set for the debuggee.

What it currently looks like:
```json
"env": {
  "NAME": "VALUE"
}
```

What the C/C++ extension expects:
```json
"environment": [
  { "name": "NAME", "value": "VALUE" }
]
```

For reference: https://code.visualstudio.com/docs/cpp/launch-json-reference#_environment
  • Loading branch information
bors committed May 26, 2024
2 parents 56d77b9 + eb9894f commit bd9cc02
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/tools/rust-analyzer/editors/code/src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ function getCCppDebugConfig(
args: runnable.args.executableArgs,
cwd: runnable.args.cwd || runnable.args.workspaceRoot || ".",
sourceFileMap,
env,
environment: Object.entries(env).map((entry) => ({
name: entry[0],
value: entry[1],
})),
// See https://github.com/rust-lang/rust-analyzer/issues/16901#issuecomment-2024486941
osx: {
MIMode: "lldb",
Expand Down

0 comments on commit bd9cc02

Please sign in to comment.