Skip to content

Commit 25f018e

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
fix: use CLI config path for debug command
If the `directories.data` is not the default, debug metadata generation can fail with false positive missing platform error. Ref: arduino/arduino-ide#1911 Signed-off-by: Akos Kitta <[email protected]>
1 parent 9c296c4 commit 25f018e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/extension.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as path from 'path';
22
import { promises as fs } from 'fs';
3+
import { homedir } from 'os';
34
import { spawn } from 'child_process';
45
import deepEqual from 'deep-equal';
56
import WebRequest from 'web-request';
@@ -44,6 +45,10 @@ interface DebugConfig {
4445
* If not defined, it falls back to `sketchPath/.vscode/launch.json`.
4546
*/
4647
readonly configPath?: string;
48+
/**
49+
* Absolute path to the `arduino-cli.yaml` file. If not specified, it falls back to `~/.arduinoIDE/arduino-cli.yaml`.
50+
*/
51+
readonly cliConfigPath?: string;
4752
}
4853

4954
interface DebugInfo {
@@ -133,10 +138,15 @@ async function exec(command: string, args: string[]): Promise<{ stdout: string,
133138
});
134139
}
135140

141+
function resolveCliConfigPath(config: DebugConfig): string {
142+
return config.cliConfigPath ?? path.join(homedir(), '.arduinoIDE', 'arduino-cli.yaml');
143+
}
144+
136145
async function startDebug(_: ExtensionContext, config: DebugConfig): Promise<boolean> {
146+
const cliConfigPath = resolveCliConfigPath(config);
137147
let info: DebugInfo | undefined = undefined;
138148
try {
139-
const args = ['debug', '-I', '-b', config.board.fqbn, config.sketchPath, '--format', 'json'];
149+
const args = ['debug', '-I', '-b', config.board.fqbn, config.sketchPath, '--format', 'json', '--config-file', cliConfigPath];
140150
const { stdout, stderr } = await exec(config?.cliPath || '.', args);
141151
if (!stdout && stderr) {
142152
throw new Error(stderr);

0 commit comments

Comments
 (0)