battery: Launching from Finder or Spotlight fails with: "Error installing battery limiter: undefined" in Ventura, but `open` command succeeds
Workaround
This is the only known way to successfully launch the Battery GUI, in my case:
- Running
open /Applications/Battery.app
from a terminal
- Update 2023-07-07: This workaround no longer works, Battery fails to launch with all methods.
Similar bugs:
Problem
Launching the “Battery” GUI app (/Applications/Battery.app
) fails when invoked by:
- Double-clicking
/Applications/Battery.app
from Finder - Running
Battery
from Spotlight - Adding
/Applications/Battery.app
toSystem Settings > Login Items > Open at Login
and rebooting
Where this specific error is emitted:
Error message:
A dialogue displays this error message:
Error installing battery limiter: undefined
Details
The error occurs regardless of the permissions of anything in ~/.battery
. No log lines appear in ~/.battery/battery.log
after the error occurs, no menulet appears in Notification Area, and no processes containing a “battery” string are spawned.
If I run open /Applications/Battery.app
from a terminal, the Battery app starts and shows its menulet in the Notification Area:
Battery.app Notification Area menulet:
System state for error reproduction:
- Mac OS: Ventura
13.3.1 (22E261)
- Battery installed only ever from Homebrew cask (version
1.1.4
), updated today - Nothing on the entire system has been installed outside of Homebrew, Nix, and the Mac App Store
- Permissions opened for config directory:
sudo chmod -Rc a+w ~/.battery
- Battery app not already running (Mac OS likely does nothing when invoking an already-running app from Finder or Spotlight)
If I kill the Battery app by clicking “Quit” on its menulet dropdown menu, then all Finder or Spotlight invocations of Battery show the error dialogue shown above in this message, until battery is run with the command: open /Applications/Battery.app
again.
So there is something wrong specifically with the Spotlight and Finder invocations of Battery.
Running processes
After running open /Applications/Battery.app
:
$ ps aux | grep -i battery | egrep -v 'grep|tail'
nhooey 84631 0.0 0.0 0 0 ?? ? 5:05PM 0:00.00 /bin/bash /usr/local/bin/battery discharge 80
nhooey 84619 0.0 0.0 0 0 ?? ? 5:05PM 0:00.00 /bin/bash /usr/local/bin/battery maintain_synchronous 80 --force-discharge
nhooey 84450 0.0 0.0 0 0 ?? ? 5:05PM 0:00.00 /Applications/Battery.app/Contents/Frameworks/battery Helper.app/Contents/MacOS/battery Helper --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --user-data-dir=/Users/nhooey/Library/Application Support/battery --shared-files --field-trial-handle=1718379636,r,18185961855328760586,18097394644492592706,131072 --disable-features=SpareRendererForSitePerProcess --seatbelt-client=45
nhooey 84443 0.0 0.0 0 0 ?? ? 5:05PM 0:00.00 /Applications/Battery.app/Contents/Frameworks/battery Helper (GPU).app/Contents/MacOS/battery Helper (GPU) --type=gpu-process --user-data-dir=/Users/nhooey/Library/Application Support/battery --gpu-preferences=UAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAALgFAAAAAAAAuAUAAAAAAADoAQAAPAAAAOABAAAAAAAA6AEAAAAAAADwAQAAAAAAAPgBAAAAAAAAAAIAAAAAAAAIAgAAAAAAABACAAAAAAAAGAIAAAAAAAAgAgAAAAAAACgCAAAAAAAAMAIAAAAAAAA4AgAAAAAAAEACAAAAAAAASAIAAAAAAABQAgAAAAAAAFgCAAAAAAAAYAIAAAAAAABoAgAAAAAAAHACAAAAAAAAeAIAAAAAAACAAgAAAAAAAIgCAAAAAAAAkAIAAAAAAACYAgAAAAAAAKACAAAAAAAAqAIAAAAAAACwAgAAAAAAALgCAAAAAAAAwAIAAAAAAADIAgAAAAAAANACAAAAAAAA2AIAAAAAAADgAgAAAAAAAOgCAAAAAAAA8AIAAAAAAAD4AgAAAAAAAAADAAAAAAAACAMAAAAAAAAQAwAAAAAAABgDAAAAAAAAIAMAAAAAAAAoAwAAAAAAADADAAAAAAAAOAMAAAAAAABAAwAAAAAAAEgDAAAAAAAAUAMAAAAAAABYAwAAAAAAAGADAAAAAAAAaAMAAAAAAABwAwAAAAAAAHgDAAAAAAAAgAMAAAAAAACIAwAAAAAAAJADAAAAAAAAmAMAAAAAAACgAwAAAAAAAKgDAAAAAAAAsAMAAAAAAAC4AwAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAGAAAAEAAAA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AoAAAAHAAAAEAAAAAAAAAAKAAAACAAAABAAAAAAAAAACgAAAAkAAAAQAAAAAAAAAAoAAAALAAAAEAAAAAAAAAAKAAAADAAAABAAAAAAAAAACgAAAA4AAAAQAAAAAAAAAAoAAAAPAAAAEAAAAAAAAAAKAAAAEAAAAAgAAAAAAAAACAAAAAAAAAA= --shared-files --field-trial-handle=1718379636,r,18185961855328760586,18097394644492592706,131072 --disable-features=SpareRendererForSitePerProcess --seatbelt-client=35
nhooey 84387 0.0 0.0 0 0 ?? ? 5:05PM 0:00.00 /Applications/Battery.app/Contents/MacOS/battery
After clicking Quit
in the Battery menulet in Notification Area:
nhooey 84631 0.0 0.0 0 0 ?? ? 5:05PM 0:00.00 /bin/bash /usr/local/bin/battery discharge 80
nhooey 84619 0.0 0.0 0 0 ?? ? 5:05PM 0:00.00 /bin/bash /usr/local/bin/battery maintain_synchronous 80 --force-discharge
These last two shell processes are never spawned if battery
is removed from System Settings > Login Items > Allow in Background
section, but the /Applications/Battery.app
GUI application continues to launch and work without issue.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (3 by maintainers)
Workaround is to just use another equivalent app called “Aldente”. It’s not all free, but it’s a lot more reliable, and the free version has enough features.
I looked at the logging code in this app and it’s really lacking some basic stuff. There’s not much chance that any of these bugs get fixed.
On Thu, Jul 20, 2023 at 18:47, Mentor Palokaj @.***> wrote:
@lucc70 @Tweoss @SangTruongTan @actuallymentor @nhooey @matphillips @rayshan @SeargantSaxton
You can fix that by following these steps. I had the same probleme yesterday $\color{green}{Step:1}$
Error installing battery limiter: undefined
just don’t uninstall it. Run this command in terminalYou should get this output
$\color{orange}{Step:2}$
Press any key to continue and hit enter, this will prompt you to enter the root password, since the shell script need root access to visudo and other privilege.
Here is a screen capture of the running command
Here is the latest version after the update via the CLI.
I had the same problem but found that if I run “battery uninstall” from command line, the GUI installer then worked fine. I figure it manages to install the CLI tools, but fails for some reason to install the GUI. Repeated attempts to install fail because it is partially installed already. Removing and reinstalling worked fine for me. Your mileage may vary 😃