arduino / ArduinoCore-megaavr

Arduino Core for the ATMEGA4809 CPU
103 stars 62 forks source link

Display useful message when Linux post-install script has insufficient permissions #138

Open per1234 opened 3 weeks ago

per1234 commented 3 weeks ago

The Arduino Boards Manager automatically executes the post_install.sh script during installation of the platform on a Linux machine:

https://arduino.github.io/arduino-cli/dev/platform-specification/#post-install-script

This platform's post-install script is intended to create a udev rules file that gives write permissions for the USB devices of the platform's boards. These permissions are required in order to upload to the boards.

The creation of the udev rules file requires superuser privileges, which are typically not available in the context of the post-install script's execution by the Arduino development software. The script contains code to check whether the necessary privileges are available. If not, it prints a message and skips the udev rules file creation.

Previously the message printed when the udev rules file creation was not possible was "Please run as root":

Downloading packages
arduino:megaavr@1.8.8
Installing platform arduino:megaavr@1.8.8
Configuring platform.
Please run as root

Platform arduino:megaavr@1.8.8 installed

That "Please run as root" message was completely meaningless to the user when printed during the Boards Manager installation. Worse, it might cause them to think they must run the Arduino development software as root user, which is a bad idea and also wouldn't result in the udev rules file being created since the installation of the platform to the user's account was already completed.

The script is here updated to provide a meaningful explanation of the potential problem as well as the specific command the user can run from the terminal to execute the script as superuser:

Downloading packages
arduino:megaavr@1.8.8
Installing platform arduino:megaavr@1.8.8
Configuring platform.

You might need to configure write permissions for uploading.
Run the following command from the terminal:
sudo "/home/per/.arduino15/packages/arduino/hardware/megaavr/1.8.8/post_install.sh"

Platform arduino:megaavr@1.8.8 installed

This is a propagation of a change originally implemented in the arduino/ArduinoCore-renesas repo: https://github.com/arduino/ArduinoCore-renesas/pull/334