Settings file not found / balena.cfg

Hello, this is my first post here :smiley:

How do I resolve this error?
Settings file not found or not in proper format. Rewriting default settings to: /root/.balena/balena.cfg

Hi @bix,

Would you mind providing a little more detail on where you are seeing that error/what device type/OS version?

Hi @xginn8,

I see that error in the Balena Logs every time my service starts.

Running on a RasPi 3 B+

balenaOS 2.24.0+rev1 (dev)

May be related to the name change as I don’t recall seeing it prior? Other thought I had was local mode messing with it - I’ve been toggling local mode off and on a bit.

Hi @bix, this message comes from the Python SDK. Could you tell us a little more about how you’re using the SDK in your application?

In general, this message isn’t something to be worried about. It’s just letting you know that a default settings file has been generated. If you’d like to get rid of it, the easiest option is to commit the generated config file as part of your application, so it isn’t regenerated from scratch in future.

Hi @pimterry,

I’ve just been testing out the SDK to figure out which aspects I may use. I’ll try committing the generated file, thank you!

I’ve logged in a few different ways (user/pass, token)

I’ve created, accessed and updated environment variables. Ran into some issues here - I can’t recall what threw the error but it was likely updating or removing given this thread: Python SDK: Creating/Updating/Removing environment variables (from device itself)

I’ve also accessed various other things - configuration, device types, tags, etc.

Couple of errors I did log (copied these commands from the SDK doc):

#AttributeError: ‘ServiceEnvVariable’ object has no attribute ‘get_all’

#TypeError: ‘DeviceServiceEnvVariable’ object is not callable

Hi @bix

I believe what you are looking for are the following snippets:


I will make sure the documentation is updated, I hope this helps!

edit: the fixup PR is here:

Hey @bix,

One more thing, the Settings file not found or not in proper format. Rewriting default settings to: /root/.balena/balena.cfg is a warning when the SDK can’t find a proper setting file (no setting file, missing mandatory keys or incorrect format…), it will try to back up your current setting and write a new default setting file so you just need to check the printed path like /root/.balena/ in your case to see what’s wrong.

The aforementioned PR is now merged and the docs should be now mention the correct commands.
Thanks for bringing this up.

@xginn8 @thgreasi,

Thank you both for the support! I haven’t been working with the SDK the past few days so I haven’t given the fixes a shot yet but I will post if I run into anymore problems.