abstractfoundry / lumicube-daemon

9 stars 12 forks source link

Code assumes `~/Desktop` exists #3

Open mfoo opened 1 year ago

mfoo commented 1 year ago

Hello! I'm trying to get my Lumicube set up on Ubuntu 22.04.1 LTS (Server edition).

One of the problems I've found is that the code assumes that ~/Desktop exists. If you use the Raspberry Pi Imager tool to flash the latest Ubuntu Server LTS then this directory isn't created for the ubuntu user (no UI, so no need for a desktop).

It's referenced in a few places including here:

https://github.com/abstractfoundry/lumicube-daemon/blob/89fb32e37a45ef87ceb75c1cc6401082dfdde61e/src/main/java/com/abstractfoundry/daemon/script/ScriptExecutor.java#L98

This results in an exception with a message of "No such file or directory" when trying to run a script in the web UI.

I've worked around this for now just by creating the Desktop folder but I'm not sure what the correct fix is. I can see the Python scripts using it for autumn_image so I'm guessing it needs to be writeable/persistent (maybe $HOME isn't correct?). Otherwise, from strace, I can see temp directories being used such as /tmp/foundry-script-context-220715112276206405 - maybe this could be used as the working directory for ProcessBuilder instead?

abstractfoundry commented 1 year ago

This is a good question. To be honest, I've been quite surprised at how many people are using the LumiCube with OS versions other than the desktop version of Raspberry Pi OS (32-bit). We thought that using ~/Desktop as a default directory was sensible, as if you create some file in your LumiCube script it's at least created somewhere fairly obvious (or you can specify a full path if you want). That said, we don't want to stop anyone tinkering and pushing the system in new and exciting directions. I'll have to have a think about this.

mfoo commented 1 year ago

Could Redis be used to store the scripts? It looks like it's being used as a transport mechanism for serial data already and values in Redis are limited to 512MiB so that should be plenty.

abstractfoundry commented 1 year ago

We're actually already using Redis to store the user script, but we use ~/Desktop as the current working directory for the Python process (injecting the script into the Python interpreter via STDIN).