Closed Shaav closed 1 year ago
I'm not sure how to handle this one. The candle manager code doesn't itself seem to address $HOME
.
What did you have to declare it as? Perhaps this can be fixed.
Perhaps @mrstegeman has more insight.
That's very weird. I've never seen $HOME
not be defined.
Definitely coming from Candle-manager-addon—but looking at the error, it's actually likely coming from the Arduino CLI. Here's what shows up in the log:
2021-02-04 21:31:06.160 INFO : Candle-manager-addon: Installed libraries according to Arduino CLI: Error: Unable to get user home dir: $HOME is not defined
2021-02-04 21:31:06.161 INFO : Candle-manager-addon: time="2021-02-04T21:31:06Z" level=error msg="Unable to get user home dir: $HOME is not defined"
2021-02-04 21:31:06.162 INFO : Candle-manager-addon: Unable to get user home dir: $HOME is not defined
This would show up right after selecting the device to flash when it went to try and download the binaries.
The install of webthings on Ubuntu is quite different—whereas on the pi everything went into /home/pi/.webthings and the processes were running as the user pi, 'pi', on Ubuntu it's spread out—and a little bit odd tbh. The main binary is in /usr/bin/webthings-gateway and runs as 'root'; it looks like maint code is in /opt/webthings-gateway(?) but everything else shows up in /etc/webthings-gateway including the add-ons and logs and that's where the addons are running from (as user webthings
):
root 1717 1 0 2091 2844 2 02:43 ? 00:00:00 /bin/bash /usr/bin/webthings-gateway
webthin+ 2284 1726 0 67047 40632 2 02:44 ? 00:00:02 python3 /etc/webthings-gateway/addons/Candle-manager-addon/main.py
webthin+ 2349 1726 0 119530 27564 0 02:44 ? 00:00:03 python3 /etc/webthings-gateway/addons/mysensors-adapter/main.py
The 'webthings' user was created without a home directory which I figured would be the biggest part of the problem, so I just gave it one. That did not seem to fix it. I tried editing the .service to make it run as webthings, but that failed miserably and then tried adding it to /etc/systemd/system/multi-user.target.wants/webthings-gateway.service
[Unit]
Description=WebThings Gateway
After=network.target
[Service]
Type=simple
StandardOutput=journal
StandardError=journal
WorkingDirectory=/opt/webthings-gateway
Environment="PYTHONPATH=/opt/webthings-gateway/python"
Environment="HOME=/home/webthings/"
ExecStart=/usr/bin/webthings-gateway
Restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target
And that worked—I suspect for consistency, it would be better to have specified somewhere in /etc/webthings-gateway/. Now that I actually look, it is indeed all arduino-cli stuff that ended up in the home directory:
$ ls -lah /home/webthings/
total 16K
drwxr-xr-x 4 webthings webthings 4.0K Feb 4 23:03 .
drwxr-xr-x 5 root root 4.0K Feb 4 20:42 ..
drwxr-xr-x 5 webthings webthings 4.0K Feb 4 23:01 .arduino15
drwxr-xr-x 3 webthings webthings 4.0K Feb 4 23:03 Arduino
SO. Yeah, seems to be arduino-cli that wants $HOME not Candle, but perhaps you can check if it's defined before calling arduino-cli and set it to something appropriate if it's not there?
Ah, that explains it. I'll check if the environment variables are set before the Arduino CLI is called. Thanks!
After belatedly realizing that my pi was ARMv8 and only being identified as ARMv7l because Raspbian is only 32bit, I reimaged it with Ubuntu Server 20.10. Installed webthings-gateway (which was fine). However, Candle Manager couldn't download anything because a $HOME location was not defined.
I ended up working around it by adding a declaration in the webthings-gateway .service file.