Preferences directory created on app startup even when preferences are not used
Author: StrobottiCreated Sep 28, 2026Updated Sep 28, 2026
Checklist
- I have searched the issue tracker for open issues that relate to the same problem.
- This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
Fyne creates the preferences storage directory (~/.config/fyne/<app-id>/ on Linux) during app.New() initialization, even if the application never uses Fyne's Preferences API.
This happens because newPreferences() calls p.load() which triggers storageReaderForPath(), and that function calls os.MkdirAll() even when the preferences file doesn't exist:
// In app/preferences_nonweb.go
func (p *preferences) storageReaderForPath(path string) (io.ReadCloser, error) {
file, err := os.Open(path)
if err != nil {
if os.IsNotExist(err) {
if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil { // <-- creates directory
return nil, err
}
return nil, errEmptyPreferencesStore
}
return nil, err
}
return file, nil
}How to reproduce
- Create a minimal Fyne app with an app ID but no preferences usage:
package main
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.NewWithID("com.example.test")
w := a.NewWindow("Test")
w.SetContent(widget.NewLabel("Hello"))
w.ShowAndRun()
}- Run the app on Linux
- Observe that
~/.config/fyne/com.example.test/is created, even though no preferences were set or read
Screenshots
N/A
Example code
See above.
Fyne version
2.8.1
Go compiler version
1.23.x
Operating system and version
Linux (Ubuntu, Fedora, etc.)
Additional Information
This is problematic for applications that:
- Use their own configuration storage instead of Fyne's Preferences API
- Want to keep users' config directories clean
- Follow XDG conventions with their own directory structure
Suggested fix: Only create the directory when actually writing preferences, not when attempting to read them. The storageReaderForPath function shouldn't need to create directories — it's a read operation.
Related downstream issue: https://github.com/Strobotti/linkquisition/issues/194
Source: fyne-io/fyne