Read the statement by Michael Teeuw here.
MagicMirror Failing on Raspberry Pi Zero W Rev 1.1
-
@davidgagne Electron is not available for the pi0w, armv6l
hasn’t been for yearsmy install script configures server mode and launches a local browser over that , connected to the port from the MM config
to do this. my install script changes package.json start clause to launch a runtime script I provide (run-start.sh)
I cannot think of a way that package.json was reverted without some manual intervention
check package,json for
"start":"./run-start.sh",
-
@sdetweil I’m not trying to be argumentative, but something has changed in the last two months that has caused the existing install scripts to stop working and/or caused MM to want electron.
I’m using this:
https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/raspberry.shAnd then this:
https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/fixuppm2.shExactly the way everything worked at the end of May. One of those scripts had to have changed, or the July 1 MM update has a bug. I cannot think of any other reason this isn’t working.
(See also: https://www.davidgagne.net/2024/05/30/how-to-get-magicmirror-to-run-on-a-raspberry-pi-zero-w-rev-1-1/)
-
@sdetweil Here are the contents of the package.json and run-start.sh files. Note that I have not edited anything. This is exactly how they came from the installation process.
{ "name": "magicmirror", "version": "2.27.0", "description": "The open source modular smart mirror platform.", "main": "js/electron.js", "scripts": { "start":"./run-start.sh $1", "start":"./run-start.sh $1", "server": "node ./serveronly", "install-mm": "npm install --no-audit --no-fund --no-update-notifier --only=prod --omit=dev", "install-mm:dev": "npm install --no-audit --no-fund --no-update-notifier", "install-vendor": "echo \"Installing vendor files ...\n\" && cd vendor && npm install --loglevel=error --no-audit --no-fund --no-update-notifier", "install-fonts": "echo \"Installing fonts ...\n\" && cd fonts && npm install --loglevel=error --no-audit --no-fund --no-update-notifier", "postinstall": "npm run install-vendor && npm run install-fonts && echo \"MagicMirror² installation finished successfully! \n\"", "test": "NODE_ENV=test jest -i --forceExit", "test:coverage": "NODE_ENV=test jest --coverage -i --verbose false --forceExit", "test:electron": "NODE_ENV=test jest --selectProjects electron -i --forceExit", "test:e2e": "NODE_ENV=test jest --selectProjects e2e -i --forceExit", "test:unit": "NODE_ENV=test jest --selectProjects unit", "test:prettier": "prettier . --check", "test:js": "eslint .", "test:css": "stylelint 'css/main.css' 'fonts/*.css' 'modules/default/**/*.css' 'vendor/*.css' --config .stylelintrc.json", "test:calendar": "node ./modules/default/calendar/debug.js", "config:check": "node js/check_config.js", "lint:prettier": "prettier . --write", "lint:js": "eslint . --fix", "lint:css": "stylelint 'css/main.css' 'fonts/*.css' 'modules/default/**/*.css' 'vendor/*.css' --config .stylelintrc.json --fix", "lint:staged": "lint-staged", "prepare": "[ -f node_modules/.bin/husky ] && husky || echo no husky installed." }, "repository": { "type": "git", "url": "https://github.com/MagicMirrorOrg/MagicMirror" }, "keywords": [ "magic mirror", "magicmirror", "smart mirror", "mirror UI", "modular" ], "author": "Michael Teeuw", "contributors": [ "https://github.com/MagicMirrorOrg/MagicMirror/graphs/contributors" ], "license": "MIT", "bugs": { "url": "https://github.com/MagicMirrorOrg/MagicMirror/issues" }, "homepage": "https://magicmirror.builders", "devDependencies": { "@stylistic/eslint-plugin": "^1.7.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-jest": "^27.9.0", "eslint-plugin-jsdoc": "^48.2.2", "eslint-plugin-package-json": "^0.12.1", "eslint-plugin-unicorn": "^51.0.1", "express-basic-auth": "^1.2.1", "husky": "^9.0.11", "jest": "^29.7.0", "jsdom": "^24.0.0", "lint-staged": "^15.2.2", "playwright": "^1.42.1", "prettier": "^3.2.5", "sinon": "^17.0.1", "stylelint": "^16.3.1", "stylelint-config-standard": "^36.0.0", "stylelint-prettier": "^5.0.0" }, "optionalDependencies": { "electron": "^29.1.6" }, "dependencies": { "ansis": "^2.3.0", "console-stamp": "^3.1.2", "envsub": "^4.1.0", "eslint": "^8.57.0", "express": "^4.19.2", "express-ipfilter": "^1.3.2", "feedme": "^2.0.2", "helmet": "^7.1.0", "html-to-text": "^9.0.5", "iconv-lite": "^0.6.3", "module-alias": "^2.2.3", "moment": "^2.30.1", "node-ical": "^0.18.0", "pm2": "^5.3.1", "socket.io": "^4.7.5", "suncalc": "^1.9.0", "systeminformation": "^5.22.6" }, "lint-staged": { "*": "prettier --write", "*.js": "eslint --fix", "*.css": "stylelint --fix" }, "_moduleAliases": { "node_helper": "js/node_helper.js", "logger": "js/logger.js" }, "engines": { "node": ">=18" } }
And here is run-start.sh:
#!/bin/bash # use bash instead of sh # get the folder for this file DIR=$(dirname "$0") # make sure we are running in that folder cd "$DIR" >/dev/null # check for the old untrack css script [ -f ./untrack-css.sh ] && ./untrack-css.sh # if running under docker if grep docker /proc/1/cgroup -qa; then # only start electron electron js/electron.js $1; else # not running in docker if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty export DISPLAY=:0 # Set by default display fi # get the processor architecture arch=$(uname -m) false='false' true='true' # get the config option, if any # only check non comment lines serveronly=$(grep -v '^[[:blank:]]*//' config/config.js | grep -i serveronly: | tr -d ',"'\''\r' | tr -d ' ' | awk -F/ '{print $1}' | awk -F: '{print $2}') # set default if not defined in config serveronly=${serveronly:-false} # check for xwindows running while [ 1 -eq 1 ]; do xorg=$(pgrep Xorg) if [ "$xorg." == "." ]; then # check for x on Lubuntu xorg=$(pgrep X) fi # if user set wait_for_x to some value (ANY value) if [ "$wait_for_x." != "." ]; then if [ "$xorg." != "." ]; then # then break from loop break; else # sleep for 1 second sleep 1 fi else # exit loop, not waiting, default break; fi done #check for macOS mac=$(uname) el_installed=$true if [ ! -d node_modules/electron ]; then el_installed=$false fi # # if the user requested serveronly OR # electron support for armv6l has been dropped OR # system is in text mode # if [ "$serveronly." != "$false." -o "$arch" == "armv6l" -o "$arch" == "i686" -o $el_installed == $false ] || [ "$xorg." == "." -a $mac != 'Darwin' -a "$wait_for_x." != "." ]; then t=$(ps -ef | grep "node serveronly" | grep -m1 -v color | awk '{print $2}') if [ "$t." != '.' ]; then sudo kill -9 $t >/dev/null 2>&1 fi # if user explicitly configured to run server only (no ui local) # OR there is no xwindows running, so no support for browser graphics if [ "$serveronly." == "$true." ] || [ "$xorg." == "." -a $mac != 'Darwin' -a "$wait_for_x." != "." ]; then # start server mode, node serveronly else # start the server in the background # wait for server to be ready # need bash for this exec 3< <(node serveronly) # Read the output of server line by line until one line 'point your browser' while read line; do case "$line" in *point\ your\ browser*) echo $line break ;; *) echo $line #sleep .25 ;; esac done <&3 # Close the file descriptor #exec 3<&- # lets use chrome to display here now # get the server port address from the ready message port=$(echo $line | awk -F\: '{print $4}') # start chromium # echo "Starting chromium browser now, have patience, it takes a minute" # continue to spool stdout to console tee <&3 & if [ "$external_browser." == "." ]; then # start chromium echo "Starting chromium browser now, have patience, it takes a minute" if [ $mac != 'Darwin' ]; then b="chromium" if [ $(which $b). == '.' -o $arch == 'armv6l' ]; then b='chromium-browser' fi if [ $(which $b). != '.' ]; then rm -rf ~/.config/$b 2>/dev/null r=$(mktemp -d "${TMPDIR:-/tmp}"/tmp.XXXXXXXX) "$b" -noerrdialogs -kiosk -start_maximized --new-window --site-per-process --no-zygote --no-sandbox --disable-infobars --app=http://localhost:$port --ignore-certificate-errors-spki-list --ignore-ssl-errors --ignore-certificate-errors --user-data-dir=$r 2>/dev/null rm -rf $r >/dev/null else echo "Chromium_browser not installed" # if we can't start chrome, # get the server process id ns=$(ps -ef | grep "node serveronly" | grep -m1 -v color | awk '{print $2}') # if we have the process id if [ "$ns". != "." ]; then # kill server for restart sudo kill -9 $ns >/dev/null 2>&1 fi fi else open -a "Google Chrome" http://localhost:$port --args -noerrdialogs -kiosk -start_maximized --disable-infobars --ignore-certificate-errors-spki-list --ignore-ssl-errors --ignore-certificate-errors 2>/dev/null fi else # if the external browser was specified if [ "$(which $external_browser)." != "." ]; then # launch it case ${external_browser,,} in midori ) # start midori echo "Starting $external_browser browser now, have patience, it takes a minute" "$external_browser" http://localhost:$port -e Fullscreen -e Navigationbar >/dev/null 2>&1 ;; firefox ) # start firefox "$external_browser" http://localhost:$port -kiosk >/dev/null 2>&1 ;; surf ) # start surf "$external_browser" -F http://localhost:$port >/dev/null 2>&1 ;; * ) #else echo "don't know how to launch $external_browser" esac else echo "couldn't locate $external_browser from the command shell,. check the PATH environment variable" fi fi exit fi else # we can use electron directly node_modules/.bin/electron js/electron.js $1; fi fi
-
@sdetweil And just to be thorough, here is my install.log. I don’t know what’s going on with those weird unicode characters in the log. And there are lots of “memory leak detected” that I don’t recall seeing back in May.
install starting - Thu Aug 1 11:35:10 EDT 2024 installing on armv6l processor system the os is Distributor ID: Raspbian Description: Raspbian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye total used free shared buff/cache available Mem: 429 182 71 7 175 187 Swap: 99 5 94 [96mUpdating packages ...[0m Reading package lists... [91mUpdate failed, retrying installation ...[0m [96mInstalling helper tools ...[0m Reading package lists... Building dependency tree... Reading state information... build-essential is already the newest version (12.9). curl is already the newest version (7.74.0-1.3+deb11u12). git is already the newest version (1:2.30.2-1+deb11u2). unzip is already the newest version (6.0-26+deb11u1). wget is already the newest version (1.21-1+deb11u1). wget set to manually installed. The following package was automatically installed and is no longer required: libfuse2 Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded. this should be a raspberry pi 02w increasing swap space computing size, want /var/swap=878MByte, checking existing: deleting wrong size file (104857600), generating swapfile ... of 878MBytes [96mCheck current Node installation ...[0m [93mNode.js is not installed.[0m [96mInstalling Node.js ...[0m Node release info = [38;5;79m2024-08-01 11:37:40 - Installing pre-requisites[0m Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease Reading package lists... Reading package lists... Building dependency tree... Reading state information... ca-certificates is already the newest version (20210119). curl is already the newest version (7.74.0-1.3+deb11u12). gnupg is already the newest version (2.2.27-2+deb11u2). The following package was automatically installed and is no longer required: libfuse2 Use 'sudo apt autoremove' to remove it. The following NEW packages will be installed: apt-transport-https 0 upgraded, 1 newly installed, 0 to remove and 39 not upgraded. Need to get 160 kB of archives. After this operation, 166 kB of additional disk space will be used. Get:1 http://mirror.umd.edu/raspbian/raspbian bullseye/main armhf apt-transport-https all 2.2.4 [160 kB] Fetched 160 kB in 1s (126 kB/s) Selecting previously unselected package apt-transport-https. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 106675 files and directories currently installed.) Preparing to unpack .../apt-transport-https_2.2.4_all.deb ... Unpacking apt-transport-https (2.2.4) ... Setting up apt-transport-https (2.2.4) ... Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease Get:3 https://deb.nodesource.com/node_20.x nodistro InRelease [12.1 kB] Get:4 https://deb.nodesource.com/node_20.x nodistro/main armhf Packages [8,776 B] Fetched 20.9 kB in 5s (3,822 B/s) Reading package lists... [1;34m2024-08-01 11:39:23 - Repository configured successfully.[0m [38;5;79m2024-08-01 11:39:23 - To install Node.js, run: apt-get install nodejs -y[0m [38;5;79m2024-08-01 11:39:23 - You can use N|solid Runtime as a node.js alternative[0m [1;32m2024-08-01 11:39:23 - To install N|solid Runtime, run: apt-get install nsolid -y [0m node 20.x version installer not available, doing manually Reading package lists... Building dependency tree... Reading state information... libstdc++6 is already the newest version (10.2.1-6+rpi1). The following package was automatically installed and is no longer required: libfuse2 Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded. using release tar file = node_release-v20.9.0.tar.gz node version is v20.9.0 [92mNode.js installation Done! version=v20.9.0[0m [96mCheck current NPM installation ...[0m [0mNPM currently installed. Checking version number. [0mMinimum npm version: [1mV10.1.0[0m [0mInstalled npm version: [1mV10.1.0[0m [92mNo npm upgrade necessary.[0m [96mCloning MagicMirror ...[0m [92mCloning MagicMirror Done![0m [96mInstalling dependencies ...[0m > magicmirror@2.28.0 postinstall > npm run install-vendor && npm run install-fonts && echo "MagicMirror² installation finished successfully! > " > magicmirror@2.28.0 install-vendor > echo "Installing vendor files ... > " && cd vendor && npm install --loglevel=error --no-audit --no-fund --no-update-notifier Installing vendor files ... added 10 packages in 1m > magicmirror@2.28.0 install-fonts > echo "Installing fonts ... > " && cd fonts && npm install --loglevel=error --no-audit --no-fund --no-update-notifier Installing fonts ... added 2 packages in 36s MagicMirror² installation finished successfully! > magicmirror@2.28.0 prepare > [ -f node_modules/.bin/husky ] && husky || echo no husky installed. no husky installed. added 433 packages in 19m 101 packages are looking for funding run `npm fund` for details [92mDependencies installation Done![0m package.json update for armv6l or Electron missing, completed ok setting up initial config.js [96mCheck plymouth installation ...[0m [96mSplashscreen: Checking themes directory.[0m [96mSplashscreen: Create theme directory if not exists.[0m [92mSplashscreen: Changed theme to MagicMirror successfully.[0m disable screensaver via gsettings was true and uint32 300 disable screensaver via lightdm.conf disable screensaver via lxsession install and setup pm2 pm2 not installed, installing pm2 install result (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (Use `node --trace-warnings ...` to show where the warning was created) (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit (node:2290) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit added 138 packages in 3m get the pm2 platform specific startup command startup command = sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u dvg --hp /home/dvg ------------- __/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____ _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___ _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__ _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___ _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____ _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________ _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________ _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_ _\///______________\///______________\///__\///////////////__ Runtime Edition PM2 is a Production Process Manager for Node.js applications with a built-in Load Balancer. Start and Daemonize any application: $ pm2 start app.js Load Balance 4 instances of api.js: $ pm2 start api.js -i 4 Monitor in production: $ pm2 monitor Make pm2 auto-boot at server restart: $ pm2 startup To go further checkout: http://pm2.io/ ------------- [PM2] Init System found: systemd Platform systemd Template [Unit] Description=PM2 process manager Documentation=https://pm2.keymetrics.io/ After=network.target [Service] Type=forking User=dvg LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin Environment=PM2_HOME=/home/dvg/.pm2 PIDFile=/home/dvg/.pm2/pm2.pid Restart=on-failure ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill [Install] WantedBy=multi-user.target Target path /etc/systemd/system/pm2-dvg.service Command list [ 'systemctl enable pm2-dvg' ] [PM2] Writing init configuration in /etc/systemd/system/pm2-dvg.service [PM2] Making script booting at startup... [PM2] [-] Executing: systemctl enable pm2-dvg... Created symlink /etc/systemd/system/multi-user.target.wants/pm2-dvg.service → /etc/systemd/system/pm2-dvg.service. [PM2] [v] Command successfully executed. +---------------------------------------+ [PM2] Freeze a process list on reboot via: $ pm2 save [PM2] Remove init script via: $ pm2 unstartup systemd pm2 startup command done configure the pm2 config file for MagicMirror rename pm2 process in pm2_MagicMirror.json the user is not pi change pm2_MagicMirror.json now using this config file pm2_MagicMirror_new.json start MagicMirror via pm2 now save MagicMirror pm2 config now stop MagicMirror via pm2 now [92mWe're ready! Run [1m[97mpm2 start pm2[0m[92m from the ~/MagicMirror directory to start your MagicMirror.[0m install completed - Thu Aug 1 12:08:49 EDT 2024
-
@sdetweil I scoured the forums and found someone else complaining about electron being missing.
I ran this
sudo npm i -g npm@6
and now it seems to be working fine. -
@davidgagne that makes no sense… the latest version of npm is 10.x
and you just installed v6… (maybe)do
npm -v
-
@davidgagne said in MagicMirror Failing on Raspberry Pi Zero W Rev 1.1:
MaxListenersExceededWarning: Possible EventEmitter memory
that is an npm bug… nothing we can do anything about. no impact on install
unicode… those are shell escape codes for color (the colors don’t show in the file, only on the actual console)
-
@sdetweil
npm -v
returns6.14.18
(and it takes a solid 45 seconds to do that, which seems like a very long time for such a simple command, even on a Zero). -
@davidgagne do free -m
pi is small on memory, so running off sd card a lot…
-
@sdetweil I was wrong. It’s not working fine.
It was working fine. Then I rebooted to make sure everything was fine. Comes back up with no problem.
Then I ssh-ed to it, installed a module, ran
npm install
inside the new module’s directory, executepm2 start MagicMirror
, and now MM crashes again looking for electron.So frustrating.