-
-
Notifications
You must be signed in to change notification settings - Fork 403
Fix nil dereference when core uninstall fails during upgrade #1371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix nil dereference when core uninstall fails during upgrade #1371
Conversation
@matthijskooijman can you rebase this one? |
@cmaglie, Done. Turns out some other change already fixed the nil-dereference and reduced it to printing |
I cannot see it, did you forget to push? |
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:avr@1.8.1 (...) $ chmod a-w ~/.arduino15/packages/arduino/hardware/avr/1.8.1 $ arduino-cli core install arduino:avr@1.8.2 Tool arduino:avr-gcc@7.3.0-atmel3.6.1-arduino5 already installed Tool arduino:avrdude@6.3.0-arduino17 already installed Tool arduino:arduinoOTA@1.3.0 already installed Downloading packages... arduino:avr@1.8.2 already downloaded Upgrading arduino:avr@1.8.1 with arduino:avr@1.8.2... 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:avr@1.8.2 Tool arduino:avr-gcc@7.3.0-atmel3.6.1-arduino5 already installed Tool arduino:avrdude@6.3.0-arduino17 already installed Tool arduino:arduinoOTA@1.3.0 already installed Downloading packages... arduino:avr@1.8.2 already downloaded Upgrading arduino:avr@1.8.1 with arduino:avr@1.8.2... 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
8d10189
to
dda68ac
Compare
w00ps, I pushed to this repo, rather than my fork accidentally :-) I rebased again (I didn't retest, but it seems unlikely that the latest changes would break this), and pushed to the right repo this time (and cleaned up the accidentally pushed branch too). |
Hm, seems there is still some problem with codecov in the tests: https://github.com/matthijskooijman/arduino-cli/runs/3300616293?check_suite_focus=true |
That's normal, you're missing the credentials secrets to push from your fork. Don't worry about it, if the PR checks are passing it's fine. There was a spurious integration tests failure but I restarted the workflows, hope it doesn't fail again. |
The code tried to log the wrong error, which was nil, and resulted in a
nil dereference.
This would occur 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, uninstalling the previous version
would fail (not managed by package manager) and the nil dereference
would happen:
With this fix applied, this produces a proper error message:
Please check if the PR fulfills these requirements
before creating one)
our contributing guidelines
Tests for the changes have been added (for bug fixes / features)Sorry, that would need quite a bit of work for such a trivial fix, no time for that.Docs have been added / updated (for bug fixes / features)Not applicableNot applicableUPGRADING.md
has been updated with a migration guide (for breaking changes)