From 1c026619c8ddd679310ad085bc2b74a49228ccbc Mon Sep 17 00:00:00 2001 From: Mike Johanson Date: Thu, 14 May 2026 13:52:24 -0700 Subject: [PATCH] fix(config): resolve symlinks when locating config dir os.Executable() can return a symlink path; using filepath.Dir on it anchors config beside the symlink rather than the real binary. On macOS this surfaces when /usr/local/bin/dmt-console symlinks into /usr/local/device-management-toolkit/console: the app tries to mkdir /usr/local/bin/config and fails with EACCES. --- config/config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/config.go b/config/config.go index 182264800..77afc39af 100644 --- a/config/config.go +++ b/config/config.go @@ -219,6 +219,13 @@ func resolveConfigPath(configPathFlag string) (string, error) { return "", err } + // Resolve symlinks so invocation via a wrapper symlink (e.g. /usr/local/bin/dmt-console + // → /usr/local/device-management-toolkit/console) anchors config beside the real binary + // rather than beside the symlink. + if resolved, evalErr := filepath.EvalSymlinks(ex); evalErr == nil { + ex = resolved + } + exPath := filepath.Dir(ex) return filepath.Join(exPath, "config", "config.yml"), nil