Skip to content

Commit 88578fb

Browse files
authored
[chore][setup]: misleading idf.py not found error (#1642)
The original error message posting `/tools/idf.py` not found, meanwhile the extension don't search this directory, which is misleading. This PR corrects those messages. --- BTW, I was ought to find out why this extension cannot detect my esp-idf installed with this [ArchLinux AUR repo](https://aur.archlinux.org/packages/esp-idf-git). The repo installs esp-idf to `/opt/esp-idf`, surely there is `./tools/idf.py` or `./tools/export.sh`. Even I was sure the existense of `/opt/esp-idf/tools/idf.py`, the extension still keeps yelling `/tools/idf.py` not found. Which I don't reproduce on the master branch. So it's assumed to be fixed and I'll just update your error message here. Signed-off-by: 蔡略 <[email protected]>
1 parent 52c887a commit 88578fb

File tree

3 files changed

+43
-40
lines changed

3 files changed

+43
-40
lines changed

src/setup/SetupPanel.ts

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,8 @@ export class SetupPanel {
282282
});
283283
SetupPanel.postMessage({
284284
command: "setEspIdfErrorStatus",
285-
errorMsg: `ESP-IDF is installed in ${
286-
setupArgs.existingIdfSetups[message.selectedIdfSetup].idfPath
287-
}`,
285+
errorMsg: `ESP-IDF is installed in ${setupArgs.existingIdfSetups[message.selectedIdfSetup].idfPath
286+
}`,
288287
});
289288
this.panel.webview.postMessage({
290289
command: "updateEspIdfToolsStatus",
@@ -325,40 +324,44 @@ export class SetupPanel {
325324
await commands.executeCommand("esp.component-manager.ui.show");
326325
break;
327326
case "canAccessFile":
328-
if (message.path) {
329-
const pathIdfPy = path.join(message.path, "tools", "idf.py");
330-
// Only require read and execute permissions
331-
const fileExists = await canAccessFile(pathIdfPy, fs.constants.R_OK | fs.constants.X_OK);
332-
if (!fileExists) {
333-
this.panel.webview.postMessage({
334-
command: "canAccessFileResponse",
335-
path: message.path,
336-
exists: fileExists,
337-
});
338-
} else {
339-
let versionEspIdf;
340-
if (
341-
message.currentVersion &&
342-
typeof message.currentVersion === "string"
343-
) {
344-
versionEspIdf = message.currentVersion;
345-
} else {
346-
versionEspIdf = await getEspIdfFromCMake(message.path);
347-
}
348-
// compareVersion returns a negative value if versionEspIdf is less than "5.0"
349-
const noWhiteSpaceSupport =
350-
compareVersion(versionEspIdf, "5.0") < 0;
351-
const hasWhitespace = /\s/.test(message.path);
352-
this.panel.webview.postMessage({
353-
command: "canAccessFileResponse",
354-
path: message.path,
355-
exists: fileExists,
356-
noWhiteSpaceSupport,
357-
hasWhitespace,
358-
});
359-
}
327+
if (!message.path) {
328+
break;
329+
}
330+
331+
const pathIdfPy = path.join(message.path, "tools", "idf.py");
332+
// Only require read and execute permissions
333+
const fileExists = await canAccessFile(pathIdfPy, fs.constants.R_OK | fs.constants.X_OK);
334+
if (!fileExists) {
335+
this.panel.webview.postMessage({
336+
command: "canAccessFileResponse",
337+
path: pathIdfPy,
338+
exists: fileExists,
339+
});
340+
break;
360341
}
342+
343+
let versionEspIdf: string;
344+
if (
345+
message.currentVersion &&
346+
typeof message.currentVersion === "string"
347+
) {
348+
versionEspIdf = message.currentVersion;
349+
} else {
350+
versionEspIdf = await getEspIdfFromCMake(message.path);
351+
}
352+
// compareVersion returns a negative value if versionEspIdf is less than "5.0"
353+
const noWhiteSpaceSupport =
354+
compareVersion(versionEspIdf, "5.0") < 0;
355+
const hasWhitespace = /\s/.test(message.path);
356+
this.panel.webview.postMessage({
357+
command: "canAccessFileResponse",
358+
path: pathIdfPy,
359+
exists: fileExists,
360+
noWhiteSpaceSupport,
361+
hasWhitespace,
362+
});
361363
break;
364+
362365
default:
363366
break;
364367
}
@@ -425,7 +428,7 @@ export class SetupPanel {
425428
) as string;
426429
const progressLocation =
427430
notificationMode === idfConf.NotificationMode.All ||
428-
notificationMode === idfConf.NotificationMode.Notifications
431+
notificationMode === idfConf.NotificationMode.Notifications
429432
? ProgressLocation.Notification
430433
: ProgressLocation.Window;
431434
return await window.withProgress(
@@ -559,7 +562,7 @@ export class SetupPanel {
559562
) as string;
560563
const progressLocation =
561564
notificationMode === idfConf.NotificationMode.All ||
562-
notificationMode === idfConf.NotificationMode.Notifications
565+
notificationMode === idfConf.NotificationMode.Notifications
563566
? ProgressLocation.Notification
564567
: ProgressLocation.Window;
565568
return await window.withProgress(
@@ -629,7 +632,7 @@ export class SetupPanel {
629632
) as string;
630633
const progressLocation =
631634
notificationMode === idfConf.NotificationMode.All ||
632-
notificationMode === idfConf.NotificationMode.Notifications
635+
notificationMode === idfConf.NotificationMode.Notifications
633636
? ProgressLocation.Notification
634637
: ProgressLocation.Window;
635638
return await window.withProgress(

src/views/setup/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ window.addEventListener("message", (event) => {
276276
case "canAccessFileResponse":
277277
if (!msg.exists) {
278278
store.setIdfPathError(
279-
"The path for ESP-IDF is not valid: /tools/idf.py not found."
279+
`The path for ESP-IDF is not valid: ${msg.path} not found.`
280280
);
281281
} else if (msg.noWhiteSpaceSupport && msg.hasWhitespace) {
282282
store.setIdfPathError(

src/views/setup/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const useSetupStore = defineStore("setup", () => {
167167
if (message.command === "canAccessFileResponse") {
168168
if (!message.exists) {
169169
setIdfPathError(
170-
"The path for ESP-IDF is not valid: /tools/idf.py not found."
170+
`The path for ESP-IDF is not valid: ${message.path} not found.`
171171
);
172172
} else {
173173
setIdfPathError("");

0 commit comments

Comments
 (0)