So I have these Pi Pico devices lying around since a while and decided on the weekend that it is time to take a look at how to work with them …
Following the getting started tutorial it turns out that the MicroPython side of the Pico is revolving a lot around the thonny IDE … I quickly found that the version of thonny in the archive is way to old to have the Pico support builtin, so as usual when I hit such a blocker I decided to take the 30min to quickly create a snap from upstream thonny …
… turns out that wasnt such a quick thing in the end …
When plugging in a Pico to your PC it auto-mounts under a fixed device name in /media/$USER/, so what Thonny does to detect the devices is to simply call “mount” via a subprocess call, parse the returned list of mountpoints and match for the expected device name … I indeed gave the app snap access to /media/$USER via removable-media …
… now … it turns out that “mount” actually returns also /var/lib/snapd/hostfs/media/$USER alongside with just /media/$USER … and apparently the snap tries to access the hostfs one first … which makes it fail and produce a permission denied traceback …
That made two questions materialize in my brain …
- why do we expose hostfs by default all the time, is that really necessary
- should removable-media not allow access to /var/lib/snapd/hostfs/media/$USER (being essentially the same as /media/$USER itself)
Oh, and in case anyone is interested in a quick and dirty Thonny snap, you can find the source at:
(along with a hacky patch to overcome the above issue)