  	if ui, err := file.GetSection("general"); err == nil {
  		if err := ui.MapTo(&config.General); err != nil {
  			return nil, err
--- 
-2.23.0
-
+--
+2.30.0

+			sec.NewKey("template-dirs", strings.ReplaceAll(key.String(), "@SHAREDIR@", sharedir))
+		}
+	}
 	file.NameMapper = mapName
 	config := &AercConfig{
 		Bindings: BindingConfig{
@@ -546,6 +428,9 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 	if err = config.LoadConfig(file); err != nil {
 		return nil, err
 	}


to the users home folder. Fix this by not substituting @SHAREDIR@ in the
default config until runtime.
---
 Makefile         |  2 +-
 config/config.go | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 77f5e61..98cbc11 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ aerc: $(GOSRC)
 		-o $@

 aerc.conf: config/aerc.conf.in
-	sed -e 's:@SHAREDIR@:$(SHAREDIR):g' > $@ < config/aerc.conf.in
+	cat config/aerc.conf.in > $@

 debug: $(GOSRC)
 	GOFLAGS="-tags=notmuch" \
diff --git a/config/config.go b/config/config.go
index 87d183a..cb6611a 100644
--- a/config/config.go
+++ b/config/config.go
@@ -470,6 +470,16 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 			return nil, err
 		}
 	}
