From 76702ffac1bc6017631e264d7f02594560ce63df Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 7 Jul 2020 15:53:13 +0200 Subject: [PATCH] Print a friendly message if a tool is not available See https://github.com/arduino/arduino-cli/issues/755 --- arduino/cores/tools.go | 6 ++++-- commands/upload/upload.go | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arduino/cores/tools.go b/arduino/cores/tools.go index 73450fdc8e1..d4618494dcf 100644 --- a/arduino/cores/tools.go +++ b/arduino/cores/tools.go @@ -133,8 +133,10 @@ func (tr *ToolRelease) String() string { // RuntimeProperties returns the runtime properties for this tool func (tr *ToolRelease) RuntimeProperties() *properties.Map { res := properties.NewMap() - res.Set("runtime.tools."+tr.Tool.Name+".path", tr.InstallDir.String()) - res.Set("runtime.tools."+tr.Tool.Name+"-"+tr.Version.String()+".path", tr.InstallDir.String()) + if tr.IsInstalled() { + res.Set("runtime.tools."+tr.Tool.Name+".path", tr.InstallDir.String()) + res.Set("runtime.tools."+tr.Tool.Name+"-"+tr.Version.String()+".path", tr.InstallDir.String()) + } return res } diff --git a/commands/upload/upload.go b/commands/upload/upload.go index 7e50960179f..0fc94dfcb98 100644 --- a/commands/upload/upload.go +++ b/commands/upload/upload.go @@ -193,7 +193,11 @@ func runProgramAction(pm *packagemanager.PackageManager, if requiredTools, err := pm.FindToolsRequiredForBoard(board); err == nil { for _, requiredTool := range requiredTools { logrus.WithField("tool", requiredTool).Info("Tool required for upload") - uploadProperties.Merge(requiredTool.RuntimeProperties()) + if requiredTool.IsInstalled() { + uploadProperties.Merge(requiredTool.RuntimeProperties()) + } else { + errStream.Write([]byte(fmt.Sprintf("Warning: tool '%s' is not installed. It might not be available for your OS.", requiredTool))) + } } }