homebridge: After Node Update HB is not starting

Current Situation

I use sudo hb-service update-node , it said its updated and then i use sudo hb-service restart and after that its not starting at all. So when i do ps aux --sort -%mem :HB is not present at all.
How i can check why it is not starting and what is the issue

When i try to again update node if it is the issue I got following error. : pi@stefanhome:/opt/homebridge/bin $ sudo hb-service update-node 18.15 ℹ Installing Node.js v18.15.0 over v16.19.1… ℹ Updating from NodeSource… Reading package lists… Done E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) E: Unable to lock directory /var/lib/apt/lists/ W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied) W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied) ✖ Failed to update Node.js: Command failed: apt-get update --allow-releaseinfo-change

pi@stefanhome:/var/lib/homebridge $ sudo hb-service status ℹ Testing hb-service is running on port 8581… ✖ Homebridge UI Not Running

Logs

I was not able to fin how to enable DEBUG via Linux console. 
pi@stefanhome:/var/lib/homebridge $ tail -f /var/lib/homebridge/homebridge.log
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:19 AM] Got SIGTERM, shutting down child bridge process...
[4/14/2023, 10:39:24 AM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null

Configuration

{
    "bridge": {
        "name": "StefanHome",
        "username": "0E:96:61:96:AB:62",
        "port": 51813,
        "pin": "105-77-307",
        "advertiser": "avahi"
    },
    "accessories": [
        {
            "type": "switch",
            "name": "SirenSwitch",
            "url": "mqtt://stefanhome.local:1883",
            "mqttPubOptions": {
                "retain": true
            },
            "topics": {
                "getOn": {
                    "topic": "zigbee2mqtt/Siren",
                    "apply": "returnВ JSON.parse(message).alarmВ ?В trueВ :В false;"
                },
                "setOn": {
                    "topic": "zigbee2mqtt/Siren/set",
                    "apply": "returnВ JSON.stringify({alarm:message});"
                },
                "getOnline": {
                    "topic": "zigbee2mqtt/Siren",
                    "apply": "returnВ JSON.parse(message).battery_lowВ ?В falseВ :В true;"
                }
            },
            "logMqtt": true,
            "history": true,
            "historyOptions": {
                "size": 4032
            },
            "accessory": "mqttthing",
            "_bridge": {
                "username": "0E:CA:C8:C9:B4:C0",
                "port": 51881
            }
        },
        {
            "type": "switch",
            "name": "Melody",
            "url": "mqtt://stefanhome.local:1883",
            "mqttPubOptions": {
                "retain": true
            },
            "topics": {
                "getOn": {
                    "topic": "zigbee2mqtt/Siren",
                    "apply": "returnВ JSON.parse(message).melodyВ ==В 9В ?В trueВ :В false;"
                },
                "setOn": {
                    "topic": "zigbee2mqtt/Siren/set",
                    "apply": "returnВ JSON.stringify({melody:В 9});"
                },
                "getOnline": {
                    "topic": "zigbee2mqtt/Siren",
                    "apply": "returnВ JSON.parse(message).battery_lowВ ?В falseВ :В true;"
                }
            },
            "otherValueOff": true,
            "logMqtt": true,
            "history": true,
            "historyOptions": {
                "size": 4032
            },
            "accessory": "mqttthing",
            "_bridge": {
                "username": "0E:86:F5:1C:F8:2C",
                "port": 39018
            }
        },
        {
            "accessory": "mqttthing",
            "type": "thermostat",
            "name": "SirenВ Melody",
            "url": "mqtt://stefanhome.local:1883",
            "topics": {
                "getCurrentTemperature": {
                    "topic": "zigbee2mqtt/Siren",
                    "apply": "returnВ JSON.parse(message).temperature"
                },
                "getTargetTemperature": {
                    "topic": "zigbee2mqtt/Siren",
                    "apply": "returnВ JSON.parse(message).melody"
                },
                "getTargetHeatingCoolingState": {
                    "topic": "zigbee2mqtt/Siren",
                    "apply": "returnВ JSON.parse(message).alarmВ ?В 'HEAT'В :В 'OFF'"
                },
                "getCurrentRelativeHumidity": {
                    "topic": "zigbee2mqtt/Siren",
                    "apply": "returnВ JSON.parse(message).humidity"
                },
                "setTargetHeatingCoolingState": {
                    "topic": "zigbee2mqtt/Siren/set",
                    "apply": "returnВ JSON.stringify({alarm:В messageВ ==В 'OFF'В ?В falseВ :В trueВ })"
                },
                "setTargetTemperature": {
                    "topic": "zigbee2mqtt/Siren/set",
                    "apply": "returnВ JSON.stringify({melody:В messageВ })"
                }
            },
            "temperatureDisplayUnitsValues": "CELSIUS",
            "minTemperature": 0,
            "maxTemperature": 50,
            "restrictHeatingCoolingState": [
                0,
                1
            ],
            "heatingCoolingStateValues": [
                "OFF",
                "HEAT"
            ],
            "_bridge": {
                "username": "0E:3E:75:86:87:4B",
                "port": 49306
            }
        },
        {
            "name": "influxData",
            "interval": 5,
            "_bridge": {
                "username": "0E:01:12:32:18:C6",
                "port": 44069
            },
            "accessory": "Schedule"
        },
        {
            "name": "FakeSwitch",
            "stayOccupiedDelay": 60,
            "maxOccupationTimeout": 64000,
            "occupancyLogging": true,
            "persistBetweenReboots": true,
            "startOnReboot": false,
            "lightSwitchesNames": "FakeLightSwitch",
            "statefulSwitchesNames": "FakeStetefulSwitch",
            "triggerSwitchesNames": "FakeTrigerSwitch",
            "statefulStayOnSwitchesNames": "FakeStatefulStayon",
            "triggerStayOnSwitchesNames": "FakeStatelessStayOn",
            "createMasterShutoff": true,
            "_bridge": {
                "username": "0E:13:35:DE:C4:11",
                "port": 49922
            },
            "accessory": "MagicOccupancy"
        },
        {
            "name": "LightFakeNew",
            "serial": "LightFakeNew",
            "stayOccupiedDelay": 0,
            "occupancyLogging": true,
            "persistBetweenReboots": true,
            "startOnReboot": false,
            "statefulSwitchesNames": "LightFakeNewStateful",
            "createMasterShutoff": false,
            "accessory": "MagicOccupancy"
        },
        {
            "name": "FakeNew1",
            "stayOccupiedDelay": 0,
            "occupancyLogging": true,
            "persistBetweenReboots": true,
            "startOnReboot": false,
            "statefulSwitchesNames": "FakeNewStateful",
            "createMasterShutoff": false,
            "accessory": "MagicOccupancy"
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        },
        {
            "name": "Evohome",
            "username": "recyclebin@italbar.net",
            "password": "Kum@L1s@",
            "temperatureUnit": "Celsius",
            "locationIndex": 0,
            "switchAway": true,
            "switchDayOff": true,
            "switchEco": true,
            "switchHeatingOff": true,
            "switchCustom": true,
            "platform": "Evohome",
            "_bridge": {
                "username": "0E:B8:63:69:BC:6C",
                "port": 53323
            }
        },
        {
            "mqtt": {
                "base_topic": "zigbee2mqtt",
                "server": "mqtt://10.10.10.197:1883",
                "reject_unauthorized": false,
                "keepalive": 60,
                "version": 4,
                "disable_qos": false
            },
            "defaults": {
                "exclude": false,
                "excluded_keys": [
                    "device_temperature"
                ],
                "converters": {
                    "switch": {
                        "type": "switch"
                    },
                    "occupancy": {
                        "type": "motion"
                    }
                }
            },
            "exclude_grouped_devices": false,
            "devices": [
                {
                    "id": "MovementSensor",
                    "exclude": false,
                    "excluded_keys": [
                        "illuminance_lux",
                        "device_temperature",
                        "illuminance"
                    ],
                    "converters": {
                        "switch": {
                            "type": "switch"
                        },
                        "occupancy": {
                            "type": "occupancy"
                        }
                    }
                }
            ],
            "_bridge": {
                "username": "0E:5D:CC:65:59:D2",
                "port": 38228
            },
            "platform": "zigbee2mqtt"
        },
        {
            "devices": [
                {
                    "name": "My LG TV",
                    "ip": "10.10.10.163",
                    "mac": "A8:23:FE:5A:75:B3",
                    "pollingInterval": 5,
                    "deepDebugLog": true,
                    "volumeLimit": 100,
                    "volumeControl": "both",
                    "channelControl": true,
                    "appButtons": [
                        {
                            "appId": "com.webos.app.livetv",
                            "name": "Live TV"
                        },
                        {
                            "appId": "com.webos.app.hdmi2",
                            "name": "PS5"
                        },
                        {
                            "appId": "youtube.leanback.v4",
                            "name": "YouTube"
                        }
                    ]
                }
            ],
            "_bridge": {
                "username": "0E:52:7C:C7:93:C2",
                "port": 55347
            },
            "platform": "webostv"
        },
        {
            "platform": "EufySecurity",
            "username": "C&&&&t",
            "password": "*****",
            "country": "BG",
            "ignoreStations": [],
            "ignoreDevices": [],
            "cameras": [
                {
                    "serialNumber": "T8130N63213200A4",
                    "enableCamera": true,
                    "enableButton": false,
                    "motionButton": false,
                    "rtsp": false,
                    "unbridge": true,
                    "forcerefreshsnap": false,
                    "useCachedLocalLivestream": true,
                    "videoConfig": {
                        "audio": true,
                        "maxWidth": 640,
                        "maxHeight": 480,
                        "maxFPS": 15,
                        "useSeparateProcesses": true
                    },
                    "refreshSnapshotIntervalMinutes": 360,
                    "snapshotHandlingMethod": 2
                }
            ],
            "cleanCache": true,
            "CameraMaxLivestreamDuration": 6000
        },
        {
            "name": "eWeLink",
            "username": "r***",
            "password": "****",
            "mode": "auto",
            "language": "en",
            "countryCode": "+359",
            "singleDevices": [
                {
                    "label": "Gas",
                    "deviceId": "1001555be2",
                    "deviceModel": "pow",
                    "showAs": "default"
                }
            ],
            "thDevices": [
                {
                    "label": "Pool",
                    "deviceId": "10017703e6",
                    "deviceModel": "th",
                    "showAs": "default"
                }
            ],
            "_bridge": {
                "username": "0E:19:0E:45:1E:6D",
                "port": 49218
            },
            "platform": "eWeLink"
        },
        {
            "options": {
                "username": "recyclebin@italbar.net",
                "password": "Kum@Lis@1",
                "accessId": "*****,
                "accessKey": "***",
                "lang": "en",
                "projectType": "2",
                "appSchema": "smartlife",
                "countryCode": 359,
                "debug": false
            },
            "name": "TuyaPlatform",
            "platform": "TuyaPlatform",
            "_bridge": {
                "username": "0E:EC:5D:DE:A3:A9",
                "port": 42692
            }
        }
    ],
    "disabledPlugins": []
}

Environment

  • OS: Raspberry PI
  • Software:
  • Node: v16.19.1
  • npm: 8.19.3

Process Supervisor

hb-service

Additional Context

pi@stefanhome:/var/lib/homebridge $ systemctl status homebridge ● homebridge.service - Homebridge Loaded: loaded (/lib/systemd/system/homebridge.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/homebridge.service.d └─override.conf Active: activating (auto-restart) (Result: exit-code) since Fri 2023-04-14 11:47:15 EEST; 2s ago Process: 15197 ExecStartPre=/bin/run-parts /etc/hb-service/homebridge/prestart.d (code=exited, status=0/SUCCESS) Process: 15207 ExecStart=/opt/homebridge/start.sh (code=exited, status=127) Main PID: 15207 (code=exited, status=127) CPU: 971ms pi@stefanhome:/var/lib/homebridge $

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 47 (12 by maintainers)

Most upvoted comments

So for people following this issue, here’s what’s been happening:

  • With the latest Raspberry Pi OS upgrades, the Raspberry Pi 4B now runs the 64-bit kernel, even on the 32-bit OS. This can be checked by uname -m returning aarch64 instead of armv7l;
  • hb-service update-node checks uname -m to decide what version of NodeJS to install. Because of the Pi OS change, it now installs the 64-bit version of node, which doesn’t run on the 32-bit OS. Hence the “‘node’: No such file or directory” message, even though the file exists.
  • Once node no longer runs, any software depending on it no longer runs either. This includes Homebridge, the Homebridge UI, hb-service, and npm.

Note that your Homebridge installation is still intact - you do not want to re-install Homebridge. To remedy the situation, you need to install the 32-bit version of NodeJS manually, as per @bwp91’s instructions above.

To prevent this from happening again (on the next hb-service update-node), you can force the 32-bit kernel by adding a line to /boot/config.txt:

arm_64bit=0 

After rebooting the PI, uname -m should once again report armv7l.

Note that this issue only occurs on the Raspberry Pi 4B, running the 64-bit v6.1 kernel on the 32-bit Raspberry Pi OS.

@rionshin Am thinking you have a permissions issue with the directories that apt uses ( permission denied error ).

I downgraded my test machine to match your configuration, and could not recreate the issue

sudo hb-service update-node 18.15
ℹ Installing Node.js v18.15.0 over v16.19.1...
ℹ Target: /opt/homebridge
✔ Download complete.
✔ Cleaned up npm at at /opt/homebridge/lib/node_modules/npm
✔ Installed Node.js v18.15.0
ℹ Rebuilding for Node.js v18.15.0...
rebuilt dependencies successfully
✔ Rebuilt homebridge-config-ui-x for Node.js v18.15.0.
rebuilt dependencies successfully
✔ Rebuilt plugins in /opt/homebridge/lib/node_modules for Node.js v18.15.0.
⚠ Please restart Homebridge for the changes to take effect.

sudo hb-service status
ℹ Testing hb-service is running on port 8581...
✔ Homebridge UI Running

Pls share the results of these commands

ls -l /var/lib/apt/
total 44
-rw-r--r-- 1 root root     0 Apr 16 08:50 daily_lock
-rw-r--r-- 1 root root 20876 Jan  6 11:41 extended_states
-rw-r--r-- 1 root root 12288 Jan  6 11:40 listchanges.db
drwxr-xr-x 4 root root  4096 Apr 16 08:50 lists
drwxr-xr-x 3 root root  4096 Nov 10 05:47 mirrors
drwxr-xr-x 2 root root  4096 Jan  6 22:40 periodic

ls -l /var/cache/apt/
total 65832
drwxr-xr-x 3 root root     4096 Jan  6 11:40 archives
-rw-r--r-- 1 root root 33718588 Apr 16 08:50 pkgcache.bin
-rw-r--r-- 1 root root 33676823 Apr 16 08:50 srcpkgcache.bin

One workaround for this is to run the update from within a root shell

ie

sudo su
hb-service update-node 18.15

Hello ,

I don’t have permission issues, everything is working correctly the only issue is when use hb-service update-node and then it install some wrong node version and HB is down and after that this “permission” error start pop up. There is multiple threads on this topic that hb-service update-node should not be used because it complete destroy HB. What i do to fix is just to uninstall and install HB and restore my backup. By the way i tried to elevate with sudo su, and get the same error. in same moment APT-get is working as charm without any issues. I am really disappointed that no one is responding in Discord nor here, i understand its free software but its used by tens of thousands and such issue can completely brick your smart home.

Will this fix via the edit to the /boot/config.txt file be the final fix?

It’s more of a workaround for now, imho. Also, I’m not sure if it’s possible to update /boot/config.txt through the Homebridge package, or if we’d need a new version of the image for that.

Will there be a different check for what version to download implemented?

As the linked raspberry pi firmware issue mentions, the supported way to determine the type of OS is getconf LONG_BIT instead of uname -m. We’ll need to check with oznu to update hb-service.

odd I am getting

tar -xzf node-v18.16.0-linux-armv7l.tar.xz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

removing the ‘z’ worked around that though I am back up and running on 18.6

+1, this needs to get fixed

For me I was able to recover remove all node-* related bits from the system

sudo apt-get remove nodejs
sudo rm /usr/loca/bin/node*

then re-install homebridge

sudo apt-get reinstall homebridge 

DO NOT upgrade the node version from 18.13 and ignore the warnings. This preserved my config and homebridge was back up

this is critical and needs to be fixed @Supereg @oznu