Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Don't set CLI executable bit if already set #1601

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/arduino/arduinoSettings.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import { chmod } from "fs/promises";
import { constants as fsconstants, promises as fs } from "fs";
import * as os from "os";
import * as path from "path";
import * as vscode from "vscode";
import * as WinReg from "winreg";
import * as util from "../common/util";

import { messages } from "../common/constants";
import { resolveArduinoPath } from "../common/platform";

import * as Logger from "../logger/logger";
Expand Down Expand Up @@ -248,7 +249,26 @@ export class ArduinoSettings implements IArduinoSettings {
if (bundledPath && this._useArduinoCli && !this._commandPath) {
// The extension VSIX stripped the executable bit, so we need to set it.
// 0x755 means rwxr-xr-x (read and execute for everyone, write for owner).
await chmod(bundledPath, 0o755);
// There have been reports of the executable bit already being set on M1
// Macs, but this call failing, so first check to see if the file is
// already executable.
// https://github.com/microsoft/vscode-arduino/issues/1599
let isExecutable = false;
try {
await fs.access(bundledPath, fsconstants.X_OK);
isExecutable = true;
} catch {
// Nothing to do. isExecutable is already false.
}

if (!isExecutable) {
try {
await fs.chmod(bundledPath, 0o755);
} catch (e) {
Logger.notifyUserError("arduino-cli-not-executable", e, messages.ARDUINO_CLI_NOT_EXECUTABLE + " " + bundledPath);
}
}

this._usingBundledArduinoCli = true;
Logger.traceUserData("using-bundled-arduino-cli");
this._arduinoPath = path.dirname(bundledPath);
Expand Down
1 change: 1 addition & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const messages = {
SERIAL_PORT_NOT_STARTED: "Serial Monitor has not been started.",
SEND_BEFORE_OPEN_SERIALPORT: "Please open a serial port first.",
NO_PROGRAMMMER_SELECTED: "Please select the programmer first.",
ARDUINO_CLI_NOT_EXECUTABLE: "The bundled Arduino CLI could not be marked executable. Ensure that VS Code is able to execute:",
};

export const statusBarPriority = {
Expand Down