Skip to content

Commit f632a9d

Browse files
Fix error printing when core uninstall fails during upgrade (#1371)
The code tried to log the wrong error, which was nil, hiding the real error. This originally occurred for example when a version of the core was already installed manually in the sketchbook, and you would try to install another version using arduino-cli, though that has since been fixed (arduino-cli no longer tries to uninstall cores from the sketchbook). To still reproduce this problem, you can e.g. break the permissions of an installed core: $ arduino-cli core install arduino:[email protected] (...) $ chmod a-w ~/.arduino15/packages/arduino/hardware/avr/1.8.1 $ arduino-cli core install arduino:[email protected] Tool arduino:[email protected] already installed Tool arduino:[email protected] already installed Tool arduino:[email protected] already installed Downloading packages... arduino:[email protected] already downloaded Upgrading arduino:[email protected] with arduino:[email protected]... Error upgrading platform: %!s(<nil>)... Error during install: upgrading platform: removing platform files: unlinkat /home/matthijs/.arduino15/packages/arduino/hardware/avr/1.8.1/firmwares: permission denied With this fix applied, this produces a proper error message: $ arduino-cli core install arduino:[email protected] Tool arduino:[email protected] already installed Tool arduino:[email protected] already installed Tool arduino:[email protected] already installed Downloading packages... arduino:[email protected] already downloaded Upgrading arduino:[email protected] with arduino:[email protected]... Error upgrading platform: removing platform files: unlinkat /home/matthijs/.arduino15/packages/arduino/hardware/avr/1.8.1/firmwares: permission denied... Error during install: upgrading platform: removing platform files: unlinkat /home/matthijs/.arduino15/packages/arduino/hardware/avr/1.8.1/firmwares: permission denied
1 parent 08bb76a commit f632a9d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: commands/core/install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func installPlatform(pm *packagemanager.PackageManager,
145145
// In case of error try to rollback
146146
if errUn != nil {
147147
log.WithError(errUn).Error("Error upgrading platform.")
148-
taskCB(&rpc.TaskProgress{Message: fmt.Sprintf(tr("Error upgrading platform: %s"), err)})
148+
taskCB(&rpc.TaskProgress{Message: fmt.Sprintf(tr("Error upgrading platform: %s"), errUn)})
149149

150150
// Rollback
151151
if err := pm.UninstallPlatform(platformRelease); err != nil {

0 commit comments

Comments
 (0)