Ubuntu – How to make Arduino (Snap) access serial port /dev/ttyUSB0 (or /dev/ttyACM0)

18.04arduinopermissionsserial portsnap

I have Ubuntu 18.04 LTS installed.

I installed Arduino IDE v1.8.5 as a snap with

snap install arduino-mhall119

I have added my user to dial-out group and rebooted:

sudo usermod -a -G dialout $USER

$ groups 
username adm dialout cdrom sudo dip plugdev lpadmin sambashare

I connected my Arduino Nano to the laptop, it is detected on port /dev/ttyUSB0 (ch341-uart).

$ ls /dev/ttyUSB0 -al
crw-rw---- 1 root dialout 188, 0 авг 13 11:59 /dev/ttyUSB0

I tried to upload the simpliest Blink sketch and get the following errors in the terminal:

$ arduino-mhall119.arduino 

avrdude: ser_open(): can't open device "/dev/ttyUSB0": Permission denied  
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.**

Also I have installed arduino 1.8.5 with umake – it can access serial port in usual way.

Note: we already have similar question here, but the solution was to use package from umake, not fix for the Snap.

So my question is: How to make Arduino (Snap) access serial port /dev/ttyUSB0 (or /dev/ttyACM0)?

Update: connecting serial-port to the snap fails with the following message

$ snap connect arduino-mhall119:serial-port 
error: snap "core" has no "serial-port" interface slots

Current interfaces are:

$ snap interfaces | grep arduino
:home                            arduino-mhall119,gedit,organize-my-files,vlc
:network                         arduino-mhall119,gedit,organize-my-files,pulsemixer,vlc
:unity7                          arduino-mhall119,gedit,organize-my-files,vlc
:x11                             arduino-mhall119,organize-my-files,pulsemixer,vlc
-                                arduino-mhall119:serial-port

Changing permissions of serial port to 777 with sudo chmod 777 /dev/ttyUSB0 does not help.

The following do not work too (because of syntax errors):

$ sudo snap connect arduino-mhall119:arduino
error: snap "arduino-mhall119" has no plug named "arduino"

$ snap connect arduino-mhall119:/dev/ttyUSB0
error: snap "arduino-mhall119" has no plug named "/dev/ttyUSB0"

$ snap connect arduino-mhall119
error: cannot resolve connection, plug snap name is empty

Information about YAML-manifest:

$ ls -l /snap/arduino-mhall119/current/meta/snap.yaml
-rw-r--r-- 1 root root 353 июл 28 00:20 /snap/arduino-mhall119/current/meta/snap.yaml

$ cat /snap/arduino-mhall119/current/meta/snap.yaml |grep -A 12 slots

$ cat /snap/arduino-mhall119/current/meta/snap.yaml |grep -A 5 plug
    - x11
    - unity7
    - home
    - network
    - serial-port

Best Answer

The arduino-mhall119 snap is outdated and should not be used anymore. Use the arduino snap instead.:

snap install arduino

Using that snap, the only thing you need to do is add your own user to the dailout group:

sudo usermod -a -G dialout $USER

After this, reboot your device and open Arduino IDE.

Related Question