Permission Denied Only With Arduino IDE

Sorry for asking this question for the 1000th time. I see a permission denied error on /dev/ttyACM0 but only with the Arduino IDE. I can access the port directly and can use PlatformIO.

I would like to get the Arduino IDE working so that it's easier for other potential users to use my code.

Environment:
Ubuntu 20.04 / Gnome (flashback)
Kernel 5.4.0-70-generic
$USER = will
Arduino IDE 1.8.13 - I have previously configured ESP32Arduino and Teensyduino

Here are some details about what I've tried.

I see the dialout group configured and seem to have access the port. I have a number of udev rules which were configured by the arduino IDE setup script and have tried various custom / excessively permissive rules suggested in topics like this one:

~ ls -lh /dev/ttyACM0
crw-rw---- 1 will dialout 166, 0 Apr 10 09:02 /dev/ttyACM0
~ groups
will adm tty uucp dialout cdrom sudo dip plugdev lpadmin lxd sambashare docker
~ ls -lh /dev/ttyACM0
crw-rw---- 1 will dialout 166, 0 Apr 10 09:02 /dev/ttyACM0
~ touch /dev/ttyACM0
~ ls /etc/udev/rules.d/
40-dfuse.rules          70-snap.snapd.rules    90-extraacl.rules  99-arduino-101.rules
70-snap.chromium.rules  70-snap.spotify.rules  98-openocd.rules   avrisp.rules

When uploading my sketch from the Arduino IDE there is a permission denied error:

Sketch uses 14412 bytes (50%) of program storage space. Maximum is 28672 bytes.
Global variables use 1144 bytes (44%) of dynamic memory, leaving 1416 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, /dev/ttyS4, } / {/dev/ttyS4, } => {}
PORTS {/dev/ttyS4, } / {/dev/ttyACM0, /dev/ttyS4, } => {/dev/ttyACM0, }
Found upload port: /dev/ttyACM0
/home/will/arduino-1.8.13/hardware/tools/avr/bin/avrdude -C/home/will/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_834061/leet_keyboard.ino.hex:i 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/will/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/home/will/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

After struggling to find a solution for several hours I setup PlatformIO and it worked on the first attempt:

Processing leonardo (platform: atmelavr; board: leonardo; framework: arduino)
-------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/leonardo.html
PLATFORM: Atmel AVR (3.3.0) > Arduino Leonardo
HARDWARE: ATMEGA32U4 16MHz, 2.50KB RAM, 28KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES: 
 - framework-arduino-avr 5.1.0 
 - tool-avrdude 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
Converting leet_keyboard.ino
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 8 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <MIDI Library> 5.0.2
|-- <MIDIUSB> 1.0.5
|-- <NeoPixelBus> 2.6.2
|   |-- <SPI> 1.0
|-- <EEPROM> 2.0
Building in release mode
Compiling .pio/build/leonardo/src/leet_keyboard.ino.cpp.o
Linking .pio/build/leonardo/firmware.elf
Checking size .pio/build/leonardo/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  44.7% (used 1144 bytes from 2560 bytes)
Flash: [=====     ]  50.3% (used 14426 bytes from 28672 bytes)
Configuring upload protocol...
AVAILABLE: avr109
CURRENT: upload_protocol = avr109
Looking for upload port...

Warning! Please install `99-platformio-udev.rules`. 
More details: https://docs.platformio.org/page/faq.html#platformio-udev-rules

Auto-detected: /dev/ttyACM0
Forcing reset using 1200bps open/close on port /dev/ttyACM0
Waiting for the new upload port...
Uploading .pio/build/leonardo/firmware.hex

Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: reading input file ".pio/build/leonardo/firmware.hex"
avrdude: writing flash (14426 bytes):

Writing | ################################################## | 100% 1.09s

avrdude: 14426 bytes of flash written
avrdude: verifying flash memory against .pio/build/leonardo/firmware.hex:
avrdude: load data flash data from input file .pio/build/leonardo/firmware.hex:
avrdude: input file .pio/build/leonardo/firmware.hex contains 14426 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.11s

avrdude: verifying ...
avrdude: 14426 bytes of flash verified

avrdude: safemode: Fuses OK (E:FD, H:D8, L:FF)

avrdude done.  Thank you.

======================================== [SUCCESS] Took 5.07 seconds ========================================

Terminal will be reused by tasks, press any key to close it.

Running the Arduino IDE with sudo resolves the problem, but I'd rather not have to do that.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.