Closed marcofeltmann closed 2 years ago
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.
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.
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.
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"
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.
This happens for me on Monterey on an M1 Imac.
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).
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?
For the machines without a battery, you can disable the feature with starship config battery.disabled true
.
Source: https://github.com/starship/starship/issues/1940#issuecomment-735273755
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 https://github.com/starship/starship/issues/2800#issuecomment-951956393.
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.
Current Behavior
starship
insidezsh
configured viaohmyzsh
shows the following warning:Expected Behavior
No warning expected
Additional context/Screenshots
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
Relevant Shell Configuration
Starship Configuration