Skip to content

Commit d2079d1

Browse files
committed
Fix failure to execute tool post-install script on Windows
Background ---------- Tool Dependency Installation ---------------------------- "Arduino Create Agent" performs installation and updates of the tool dependencies required for direct communication between the local machine and the target board. It might be necessary to execute some sort of installation process in addition to placing the files from the tool archive on the user's hard drive. This capability is provided by a "post-install script" system. If a post-install script file (`post_install.bat` on Windows, `post_install.sh` other host operating systems) is found in the tool installation, "Arduino Create Agent" automatically executes it as part of the tool installation operation. One of the tool dependencies is `arduino:windows-drivers`, which provides the Windows device drivers for the official Arduino boards. This tool contains a post-install script that installs the drivers from the tool archive. It is essential for this script to be executed as the presence of the driver files alone doesn't have any effect. Go `exec` Package ----------------- From the Go 1.19 release, the behavior of the `exec` package was changed to make it more secure: https://pkg.go.dev/os/exec#hdr-Executables_in_the_current_directory > as of Go 1.19, this package will not resolve a program using an implicit or explicit path entry relative to the > current directory. That is, if you run exec.LookPath("go"), it will not successfully return ./go on Unix nor .\go.exe > on Windows, no matter how the path is configured. Instead, if the usual path algorithms would result in that answer, > these functions return an error err satisfying errors.Is(err, ErrDot). Problem ------- The code that executes the post-install script on Windows depended on the previous behavior of the `exec` package. Ever since the version of Go used to build "Arduino Create Agent" was updated to 1.19, the script has not been executed: ``` { "DownloadStatus": "Error", "Msg": "exec: \"post_install.bat\": cannot run executable found relative to current directory" } ``` This means "Arduino Create Agent" never installed the drivers from the `arduino:windows-drivers` tool on the machines who weren't using it before the 1.3.0 release. The failure to execute the post-install script results in **Arduino Create Agent** attempting installation of the `arduino:windows-drivers` tool on every Arduino Cloud session. Even if the user is not impacted by the lack of drivers (either because it is not required for their board, or because they installed the drivers via some other mechanism), they will still be annoyed and confused by the frequent appearance of the "**Installing drivers**" dialog that is produced by **Arduino Create Agent**'s post-install script execution code.
1 parent 6aa8183 commit d2079d1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/download.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ func findTool(pack, name, version string, data pkgs.Index) (pkgs.Tool, pkgs.Syst
223223
func (t *Tools) installDrivers(location string) error {
224224
OkPressed := 6
225225
extension := ".bat"
226-
preamble := ""
226+
// add .\ to force locality
227+
preamble := ".\\"
227228
if OS != "windows" {
228229
extension = ".sh"
229230
// add ./ to force locality

0 commit comments

Comments
 (0)