Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

battery module warning on desktop macOS 12 #2800

Closed
marcofeltmann opened this issue Jun 14, 2021 · 10 comments · Fixed by #3213
Closed

battery module warning on desktop macOS 12 #2800

marcofeltmann opened this issue Jun 14, 2021 · 10 comments · Fixed by #3213
Labels
🐛 bug Something isn't working as expected. 🌊 upstream Depends on an upstream solve beyond starship

Comments

@marcofeltmann
Copy link

Current Behavior

starship inside zsh configured via ohmyzsh shows the following warning:

[WARN] - (starship::modules::battery): Unable to access battery information:
FullyCharged

Expected Behavior

No warning expected

Additional context/Screenshots

Bildschirmfoto 2021-06-14 um 18 23 07

Possible Solution

Temporarily disabled battery information since the Mac Mini does not have batteries anyway.
May happen on MacBook Pro M1 w/ macOS 12 beta as well…

Environment

  • Starship version: 0.54.0
  • zsh version: zsh 5.8 (x86_64-apple-darwin21.0)
  • Operating system: Mac OS 12.0.0
  • Terminal emulator: Apple_Terminal 440
  • Git Commit Hash:
  • Branch/Tag:
  • Rust Version: rustc 1.51.0
  • Rust channel: release
  • Build Time: 2021-05-15 07:25:03

Relevant Shell Configuration

# Keep system path before adding stuff to user path
SYSPATH=$PATH

# Adds Go Tools to path
PATH=/Users/marcofeltmann/go/bin:

# Adds Android Tooling to path
PATH+=/Users/marcofeltmann/sysroots/Android/sdk/tools:/Users/marcofeltmann/sysroots/Android/sdk/platform-tools:

# Append system path and export it eventually.
PATH+=$SYSPATH
export PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/marcofeltmann/.oh-my-zsh"

ZSH_THEME="robbyrussell"

plugins=(git)

source $ZSH/oh-my-zsh.sh

eval "$(starship init zsh)"

Starship Configuration

<no config>
@marcofeltmann marcofeltmann added the 🐛 bug Something isn't working as expected. label Jun 14, 2021
@kidonng
Copy link
Contributor

kidonng commented Jun 20, 2021

May happen on MacBook Pro M1 w/ macOS 12 beta as well…

I'm also on beta and have no issue. OS is no related.

image

Expected Behavior

No warning expected

Technically speaking, the warning is expected.

Temporarily disabled battery information since the Mac Mini does not have batteries anyway.

We can't tell whether you system does not have batteries or something goes wrong. Only thing we can do is to silence the message, but that's not good. Or you can disable the battery module.

@matchai
Copy link
Member

matchai commented Jun 20, 2021

Can you please share your starship logs where you encounter the error:

STARSHIP_LOG=trace starship prompt

Most of the heavy-lifting for the battery module is done by svartalf/rust-battery, so this may require an upstream issue to be created if we're receiving an unparsable output on M1 desktop machines.

@andytom andytom added the needs info Needs more information from the issue creator. label Jul 14, 2021
@egoist
Copy link

egoist commented Aug 9, 2021

here's the related debug logs:

[DEBUG] - (starship::utils): Error reading file: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" })
[TRACE] - (starship::utils): Trying to read from "/Users/egoist/vpkg.json"
[WARN] - (starship::modules::battery): Unable to access battery information:
FullyCharged
[TRACE] - (starship::utils): Executing command "git" with args ["-C", "/Users/egoist", "--no-optional-locks", "stash", "list"]
[DEBUG] - (starship::utils): Error reading file: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" })
[TRACE] - (starship::modules): Took 5.426666ms to compute module "package"
[TRACE] - (starship::config): No config found for "package": Option "package" not found
[TRACE] - (starship::modules): Took 620.916µs to compute module "battery"

@matchai matchai removed the needs info Needs more information from the issue creator. label Aug 9, 2021
@matchai
Copy link
Member

matchai commented Aug 9, 2021

Heya EGOIST 👋
Thanks for the logs. Unfortunately, it doesn't look like there's a whole lot else to work with.

What's unusual is that it seems rust-battery provides us with an Error, though we still get a sensible battery state of FullyCharged, which doesn't seem like something I remember seeing on other desktop machines. 🤔
If this appears as a unique combination on M1 desktop machines, perhaps we can specifically handle this case differently.

@dmd
Copy link

dmd commented Oct 25, 2021

This happens for me on Monterey on an M1 Imac.

@mogita
Copy link

mogita commented Oct 26, 2021

It happens for me too on Monterey 12.0.1 on an M1 iMac 2021.
Starship version 0.58.0.
zsh version 5.8 (x86_64-apple-darwin21.0).

@nomaed
Copy link
Contributor

nomaed commented Oct 26, 2021

Can confirm the same on Mac mini (M1, 2020) after the upgrade.

I am not familiar with the codebase, but is it possible to add an exception so that an Error of "FullyCharged" will be treated like no error?

@mogita
Copy link

mogita commented Oct 26, 2021

For the machines without a battery, you can disable the feature with starship config battery.disabled true.

Source: #1940 (comment)

@kidonng
Copy link
Contributor

kidonng commented Oct 27, 2021

As mentioned by @matchai the heavy lifting is done by the battery crate, so it's best to open an issue there and ask for help.

If this warning does not appear on previous versions of macOS then it's Apple changing stuff. The code for darwin platform in battery crate hasn't been updated for over a year, probably that's the issue.

For now the best thing you can do is to disable the battery module on machines without a battery, as commented in #2800 (comment).

@kidonng kidonng added the 🌊 upstream Depends on an upstream solve beyond starship label Oct 27, 2021
@kidonng kidonng changed the title Battery Module warning on macOS 12 beta battery module warning on macOS 12 Oct 27, 2021
@horasal
Copy link

horasal commented Nov 1, 2021

It seems that fully_charged and designed_capacity are missing on recent macOS so I opened a PR https://github.com/svartalf/rust-battery/pull/93/files avoiding rust-battery throws errors when these two keys are empty.

@matchai matchai changed the title battery module warning on macOS 12 battery module warning on desktop macOS 12 Nov 2, 2021
matchai added a commit that referenced this issue Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working as expected. 🌊 upstream Depends on an upstream solve beyond starship
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants