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

Error when running battery charging off with latest version #8

Closed
anarchy89 opened this issue Sep 26, 2022 · 5 comments
Closed

Error when running battery charging off with latest version #8

anarchy89 opened this issue Sep 26, 2022 · 5 comments

Comments

@anarchy89
Copy link

After updating the app, when I run battery charging off, I keep getting the following error,

touch: /Users/xxx/.battery/battery.log: Permission denied 15:47:15 - Setting charging to off touch: /Users/xxx/.battery/battery.log: Permission denied touch: /Users/xxx/.battery/battery.log: Permission denied 15:47:15 - Enabling battery charging touch: /Users/xxx/.battery/battery.log: Permission denied 15:47:15 - Battery at 63% ((no remaining), smc charging enabled 15:47:15 - Disabling battery charging

I am unable to access the .battery folder. I have tried deleting the folder and reinstalling battery as well. Still get the same error.

I also ran sudo battery visudo. Still have the same error.

@actuallymentor
Copy link
Owner

You'll have to run sudo rm -rf ~/.battery and battery reinstall in theory it should work after.

Please let me know if that fixes it.

@anarchy89
Copy link
Author

Hey it worked @actuallymentor , thanks! You should add this to the readme. I reckon it happens a lot.

@Evertt
Copy link

Evertt commented Oct 8, 2022

I have the same problem.

You'll have to run sudo rm -rf ~/.battery and battery reinstall in theory it should work after.

This did not fix it for me. And just want to add one more interesting bit of information. When I run battery in my terminal, the first line of output says touch: /Users/evert/.battery/battery.log: Permission denied.

Then as a sanity check, I just tried to run that command myself: touch /Users/evert/.battery/battery.log and even I got Permission denied. Which I thought was odd, because I assumed that I could do anything I pleased in my own home folder.

After running ls -al ~/.battery I see that battery.log actually already exists and that is owned by the root user.

Even though I'm sure that nowhere during the installation process did I intentionally give any process root acces. But it may of course be possible, because the app did ask me to fill in my password one time to install additional components. So maybe the app is using that password accidentally to give itself root access while installing those additional components. And so yes, if it then also created /Users/evert/.battery/battery.log then that could explain why that file now belongs to the root user.

So I just deleted that log file by force. And then when I ran battery again, it didn't show an error as the first line. Then when I ran ls -al ~/.battery I could see a newly created battery.log file which is not owned by root anymore, but instead by me. And now when I open up the app, I don't get those error popups that OP showed. And when I turn on the 80% charging limit, it works as expected. So this seems to have solved the problem for me.

Hope this information can help you to fix this issue better.

@chrisfromredfin
Copy link

I installed with homebrew and was having this issue. I just ran sudo chown $(whoami) /Users/$(whoami)/.battery/battery.log and it stopped.

@actuallymentor
Copy link
Owner

Hey all!

Thanks for doing a dive into this, I appreciate it.

This issue should only occur if you had a previous version installed. The beta/RC versions messed up some things (my bad), and it should not happen in the future.

If anyone finds this thread, things you can do to attempt a fix:

sudo rm -rf ~/.battery
binfolder=/usr/local/bin
sudo rm -v "$binfolder/smc" "$binfolder/battery"

And to reinstall use brew (if you have it):

brew install battery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants