Serial port permissions for a snap (Arduino IDE)


#1

I’m trying to use the Arduino IDE snap (arduino-mhall119) in Ubuntu 18.04 to upload the simple blinking code example to a Seeeduino Lotus v1.1 (to USB port dev/ttyUSB0) or an Arduino Uno (to USB port dev/ttyACM0). This gives me the following error messages respectively.

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.

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

Because the permission is denied, my next trouble shooting step would be to run the snap as root. It would be good if this option was available as a GUI option, but since I could not find one for the snap. I tried sudo arduino-mhall119.arduino and got the following errors:

mkdir: cannot create directory '/run/user/0': Permission denied
ln: failed to create symbolic link '/root/snap/arduino-mhall119/5/snap/arduino-mhall119/5/Documents': No such file or directory
ln: failed to create symbolic link '/root/snap/arduino-mhall119/5/snap/arduino-mhall119/5/Desktop': No such file or directory
ln: failed to create symbolic link '/root/snap/arduino-mhall119/5/snap/arduino-mhall119/5/Downloads': No such file or directory
ln: failed to create symbolic link '/root/snap/arduino-mhall119/5/snap/arduino-mhall119/5/Music': No such file or directory
ln: failed to create symbolic link '/root/snap/arduino-mhall119/5/snap/arduino-mhall119/5/Pictures': No such file or directory
ln: failed to create symbolic link '/root/snap/arduino-mhall119/5/snap/arduino-mhall119/5/Videos': No such file or directory
ln: failed to create symbolic link '/root/snap/arduino-mhall119/5/snap/arduino-mhall119/5/Templates': No such file or directory
No protocol specified
Picked up JAVA_TOOL_OPTIONS: 
No protocol specified
java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
	at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
	at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
	at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103)
	at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
	at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:126)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at java.awt.Toolkit$2.run(Toolkit.java:860)
	at java.awt.Toolkit$2.run(Toolkit.java:855)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:854)
	at java.awt.SystemColor.updateSystemColors(SystemColor.java:473)
	at java.awt.SystemColor.<clinit>(SystemColor.java:465)
	at processing.app.Theme.init(Theme.java:84)
	at processing.app.Base.<init>(Base.java:219)
	at processing.app.Base.main(Base.java:144)

I seem not to be able to run the snap as root. Does anyone have a solution to do this via the GUI and have it permanently start up in root?

Thanks a lot :slight_smile:

UPDATE: I found out that in the Ubuntu Software centre (where I installed the snap) there is a permission option to “Access serial port hardware” (see picture below). That could fix the permission issue! However, after clicking that and being prompted for my root password, I can only change it to the setting ‘(disconnected)’ and nothing else. This seems very odd to me.
Can anyone explain why this is and perhaps fix this serial permission non-availability?


#2

This depends on the upcoming feature where snapd discovers devices that are available on the system and creates snapd interfaces (slots) on demand. CC @pstolowski for updates.


#3

You shouldn’t run the snap as root, it’s made to be run as a normal user.

However, to get around the serial ports being blocked, you will need to install it with the --devmode flag. This, unfortunately, disables all security confinement for the snap, but until the new feature that @zyga mentioned becomes available it’s the easiest way to let the Arduino IDE talk to devices.


#4

Hi…I was having the same problem and your solution worked for me. I don’t understand though. A few months back my Arduino IDE was working fine, I didn’t change anything, and now I just wasted 3 hours, added permissions to the ttyUSB0 (which were there to begin with), I already belonged to the group dialout, rebooted multiple times and prayed over and over.