From d73164f258d872d44c2184c5021af0eae0afcd3b Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Tue, 5 Nov 2024 07:09:14 +0900 Subject: [PATCH 1/2] fix(which): search config file paths even if AQUA_CONFIG is given --- pkg/controller/which/which.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/controller/which/which.go b/pkg/controller/which/which.go index 013f03fa8..72f5d0f33 100644 --- a/pkg/controller/which/which.go +++ b/pkg/controller/which/which.go @@ -23,7 +23,11 @@ type FindResult struct { } func (c *Controller) Which(ctx context.Context, logE *logrus.Entry, param *config.Param, exeName string) (*FindResult, error) { - for _, cfgFilePath := range c.configFinder.Finds(param.PWD, param.ConfigFilePath) { + var filePaths []string + if param.ConfigFilePath != "" { + filePaths = []string{param.ConfigFilePath} + } + for _, cfgFilePath := range append(filePaths, c.configFinder.Finds(param.PWD, "")...) { findResult, err := c.findExecFile(ctx, logE, param, cfgFilePath, exeName) if err != nil { return nil, err From 264c72070a8bf0c141af62466d81149fe9f1e531 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Tue, 5 Nov 2024 07:18:30 +0900 Subject: [PATCH 2/2] fix: change file path to the absolute path --- pkg/controller/which/which.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/controller/which/which.go b/pkg/controller/which/which.go index 72f5d0f33..a97b58711 100644 --- a/pkg/controller/which/which.go +++ b/pkg/controller/which/which.go @@ -9,6 +9,7 @@ import ( "github.com/aquaproj/aqua/v2/pkg/config" "github.com/aquaproj/aqua/v2/pkg/config/aqua" "github.com/aquaproj/aqua/v2/pkg/config/registry" + "github.com/aquaproj/aqua/v2/pkg/osfile" "github.com/sirupsen/logrus" "github.com/suzuki-shunsuke/logrus-error/logerr" ) @@ -25,7 +26,7 @@ type FindResult struct { func (c *Controller) Which(ctx context.Context, logE *logrus.Entry, param *config.Param, exeName string) (*FindResult, error) { var filePaths []string if param.ConfigFilePath != "" { - filePaths = []string{param.ConfigFilePath} + filePaths = []string{osfile.Abs(param.PWD, param.ConfigFilePath)} } for _, cfgFilePath := range append(filePaths, c.configFinder.Finds(param.PWD, "")...) { findResult, err := c.findExecFile(ctx, logE, param, cfgFilePath, exeName)