@@ -23,6 +23,7 @@ import (
23
23
"encoding/json"
24
24
"flag"
25
25
"os"
26
+ "os/exec"
26
27
"runtime"
27
28
"runtime/debug"
28
29
"strconv"
@@ -168,6 +169,15 @@ func loop() {
168
169
log .SetLevel (log .InfoLevel )
169
170
log .SetOutput (os .Stdout )
170
171
172
+ // We used to install the agent in $HOME/Applications before versions <= 1.2.7-ventura
173
+ // With version > 1.3.0 we changed the install path of the agent in /Applications.
174
+ // If we are updating manually from 1.2.7 to 1.3.0 we have to uninstall the old agent manually first.
175
+ // This check will inform the user if he needs to run the uninstall first
176
+ if runtime .GOOS == "darwin" && oldInstallExists () {
177
+ printDialog ("Old agent installation of the Arduino Create Agent found, please uninstall it before launching the new one" )
178
+ os .Exit (0 )
179
+ }
180
+
171
181
// Instantiate Tools
172
182
Tools = tools.Tools {
173
183
Directory : config .GetDataDir ().String (),
@@ -434,6 +444,18 @@ func loop() {
434
444
}()
435
445
}
436
446
447
+ // oldInstallExixts will return true if an old installation of the agent exixts (on macos)
448
+ func oldInstallExists () bool {
449
+ oldAgentPath := config .GetDefaultHomeDir ().Join ("Applications" , "ArduinoCreateAgent" )
450
+ return oldAgentPath .Exist ()
451
+ }
452
+
453
+ // printDialog will print a GUI error dialog on macos
454
+ func printDialog (dialogText string ) {
455
+ oscmd := exec .Command ("osascript" , "-e" , "display dialog \" " + dialogText + "\" buttons \" OK\" with title \" Error\" " )
456
+ _ = oscmd .Run ()
457
+ }
458
+
437
459
func parseIni (filename string ) (args []string , err error ) {
438
460
cfg , err := ini .LoadSources (ini.LoadOptions {IgnoreInlineComment : false , AllowPythonMultilineValues : true }, filename )
439
461
if err != nil {
0 commit comments