arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.33k stars 394 forks source link

Permission Denied When Uploading Program on Pop!_OS (Arduino IDE 2.3.2) #2494

Closed Arthur-Barreto closed 3 months ago

Arthur-Barreto commented 3 months ago

Describe the problem

After installing the latest version of the Arduino IDE (2.3.2) on Pop!_OS, I encountered a "Permission Denied" error while trying to upload the Blink example code to the built-in LED on my Arduino device. The error message is as follows:

Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
Failed uploading: uploading error: exit status 1

To reproduce

1) Download and install Arduino IDE version 2.3.2 on a system running Pop!_OS. 2) Open the Blink example code from the IDE. 3) Attempt to upload the code to an Arduino UNO board

Expected behavior

The upload should fail with a "Permission Denied" error, as shown in the error message above.

Arduino IDE version

2.3.2

Operating system

Linux

Operating system version

22.04

Additional context

The issue can be resolved by adding the current user to the dialout group, which grants the necessary permissions to access the serial port. Run the following command in the terminal:

sudo usermod -aG dialout $USER

Issue checklist

per1234 commented 3 months ago

Hi @Arthur-Barreto. As you already discovered, this was caused by your Linux user account not having write permission for the device.

Arduino IDE is a general purpose tool that is designed to be used with any of the ever growing thousands of boards and microcontrollers in the Arduino ecosystem. For this reason, we intentionally do not implement anything specific to a particular board in this code base and thus the configuration of permissions necessary for communication between the arbitrary upload tool and an arbitrary board is completely out of scope for the Arduino IDE project.

The place to do such things is in the Arduino boards platform that adds support for a given board. The boards platform framework does provide support for running a script when the platform is installed via the Arduino IDE Boards Manager:

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

This script can't be used to configure the Linux permissions since this requires superuser privileges which Arduino IDE does not and should not have. However, it is possible to use the script to communicate to the user the possible need to configure the permissions, and how to do that. We have recently done this in several of the official Arduino boards platforms:

I would definitely encourage the developers of other platforms for boards that might require the configuration of Linux permissions (or other other external configuration) to do something similar as I think this does have potential to significantly improve the user experience.

Arduino also provides documentation for configuring permissions:

https://docs.arduino.cc/software/ide-v2/tutorials/getting-started/ide-v2-uploading-a-sketch/#please-read-only-linux-users

https://docs.arduino.cc/software/ide-v1/tutorials/Linux/#please-read

https://support.arduino.cc/hc/en-us/articles/360016495679-Fix-port-access-on-Linux