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:

  1. 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:

  1. Double-clicking /Applications/Battery.app from Finder
  2. Running Battery from Spotlight
  3. Adding /Applications/Battery.app to System 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
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:

image

System state for error reproduction:

  1. Mac OS: Ventura 13.3.1 (22E261)
  2. Battery installed only ever from Homebrew cask (version 1.1.4), updated today
  3. Nothing on the entire system has been installed outside of Homebrew, Nix, and the Mac App Store
  4. Permissions opened for config directory: sudo chmod -Rc a+w ~/.battery
  5. 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=UAAAAAAAAAAgAAAIAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAALgFAAAAAAAAuAUAAAAAAADoAQAAPAAAAOABAAAAAAAA6AEAAAAAAADwAQAAAAAAAPgBAAAAAAAAAAIAAAAAAAAIAgAAAAAAABACAAAAAAAAGAIAAAAAAAAgAgAAAAAAACgCAAAAAAAAMAIAAAAAAAA4AgAAAAAAAEACAAAAAAAASAIAAAAAAABQAgAAAAAAAFgCAAAAAAAAYAIAAAAAAABoAgAAAAAAAHACAAAAAAAAeAIAAAAAAACAAgAAAAAAAIgCAAAAAAAAkAIAAAAAAACYAgAAAAAAAKACAAAAAAAAqAIAAAAAAACwAgAAAAAAALgCAAAAAAAAwAIAAAAAAADIAgAAAAAAANACAAAAAAAA2AIAAAAAAADgAgAAAAAAAOgCAAAAAAAA8AIAAAAAAAD4AgAAAAAAAAADAAAAAAAACAMAAAAAAAAQAwAAAAAAABgDAAAAAAAAIAMAAAAAAAAoAwAAAAAAADADAAAAAAAAOAMAAAAAAABAAwAAAAAAAEgDAAAAAAAAUAMAAAAAAABYAwAAAAAAAGADAAAAAAAAaAMAAAAAAABwAwAAAAAAAHgDAAAAAAAAgAMAAAAAAACIAwAAAAAAAJADAAAAAAAAmAMAAAAAAACgAwAAAAAAAKgDAAAAAAAAsAMAAAAAAAC4AwAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAA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AAAAYAAAAQAAAAAAAAAAoAAAAHAAAAEAAAAAAAAAAKAAAACAAAABAAAAAAAAAACgAAAAkAAAAQAAAAAAAAAAoAAAALAAAAEAAAAAAAAAAKAAAADAAAABAAAAAAAAAACgAAAA4AAAAQAAAAAAAAAAoAAAAPAAAAEAAAAAAAAAAKAAAAEAAAAAgAAAAAAAAACAAAAAAAAAA= --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)

Most upvoted comments

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:

This is very strange and I have no idea what the source of this could me… If anyone has ideas, please let me know!

— Reply to this email directly, view it on GitHub https://github.com/actuallymentor/battery/issues/133#issuecomment-1643779386, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAP7MU74CDMP24S3IH26N3XRELFTANCNFSM6AAAAAAXINTHCI . You are receiving this because you authored the thread.Message ID: @.***>

@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}$

  • Ensure that the Battery is installed, even if you have the following error message Error installing battery limiter: undefined just don’t uninstall it. Run this command in terminal
which battery

You should get this output

/usr/local/bin/battery

$\color{orange}{Step:2}$

  • Run the following command to update the Battery app from the command line. this will call the shell script and download the latest script from the git repo and execute the installation via bash.
battery reinstall

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

image

Here is the latest version after the update via the CLI.

image

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 😃