From bff5006f401c8a78b1a890fbc3f0cda402dc7dde Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Thu, 24 Oct 2024 09:14:24 +0200 Subject: [PATCH] detect project dir is a symlink and warn user Signed-off-by: Nicolas De Loof --- cli/options.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/options.go b/cli/options.go index c4b2f57a..c0e6c965 100644 --- a/cli/options.go +++ b/cli/options.go @@ -502,8 +502,13 @@ func withNamePrecedenceLoad(absWorkingDir string, options *ProjectOptions) func( } else if nameFromEnv, ok := options.Environment[consts.ComposeProjectName]; ok && nameFromEnv != "" { opts.SetProjectName(nameFromEnv, true) } else { + dirname := filepath.Base(absWorkingDir) + symlink, err := filepath.EvalSymlinks(absWorkingDir) + if err == nil && filepath.Base(symlink) != dirname { + logrus.Warnf("project has been loaded without an explicit name from a symlink. Using name %q", dirname) + } opts.SetProjectName( - loader.NormalizeProjectName(filepath.Base(absWorkingDir)), + loader.NormalizeProjectName(dirname), false, ) }