Udevadm trigger inside devmode Snap help?

Our Snap is built using –devmode and runs as root. It is not intended for the Snap Store.

It manages custom USB devices. We have the ability on our device to disable power to any USB port. However, it appears Linux does not de-enumerate when power is disable and one must trigger a udev rule to fully remove the device from Ubuntu Core.

The command to do this is: udevadm trigger --action=remove /sys/bus/usb/devices/2-1.4.6/

However, when executing this command inside the Snap I get ‘Running in chroot, ignoring request’ whether I use sudo or not.

Per googling, supposedly if you add a hardware-observe and/or snapd-control plug it should provide privileges so this can work – but none of this works? I still get the chroot errror. I already have raw-usb plug

How can I provide my Snap privs it needs to run udevadm trigger then?

Appreciate any help,

Will

It is not a snap privilege issue, but a systemd behavior:

Try setting the SYSTEMD_IN_CHROOT environment variable to false before running that command:

Thank you for responding so quickly. I tried the following all with same failure

(poller) root@thio-lab-0:/var/snap/thio/current/thio/utils# SYSTEMD_IN_CHROOT=false;udevadm trigger --action=remove /sys/bus/usb/devices/2-1.4.6/ Running in chroot, ignoring request.

(poller) root@thio-lab-0:/var/snap/thio/current/thio/utils# export SYSTEMD_IN_CHROOT=false;sudo udevadm trigger --action=remove /sys/bus/usb/devices/2-1.4.6/ Running in chroot, ignoring request.

(poller) root@thio-lab-0:/var/snap/thio/current/thio/utils# export SYSTEMD_IN_CHROOT=0;sudo udevadm trigger --action=remove /sys/bus/usb/devices/2-1.4.6/ Running in chroot, ignoring request.

(poller) root@thio-lab-0:/var/snap/thio/current/thio/utils# export SYSTEMD_IN_CHROOT=0;udevadm trigger --action=remove /sys/bus/usb/devices/2-1.4.6/ Running in chroot, ignoring request.

Note:

(poller) root@thio-lab-0:/var/snap/thio/current/thio/utils# whoami

root