@@ -39,7 +39,7 @@ func Check(opts CheckOptions) error {
3939 }
4040
4141 // Resolve mx binary
42- mxPath , err := resolveMx (opts .MxBuildPath )
42+ mxPath , err := ResolveMx (opts .MxBuildPath )
4343 if err != nil {
4444 return err
4545 }
@@ -67,9 +67,9 @@ func mxBinaryName() string {
6767 return "mx"
6868}
6969
70- // resolveMx finds the mx executable.
70+ // ResolveMx finds the mx executable.
7171// Priority: derive from mxbuild path > PATH lookup.
72- func resolveMx (mxbuildPath string ) (string , error ) {
72+ func ResolveMx (mxbuildPath string ) (string , error ) {
7373 if mxbuildPath != "" {
7474 // Resolve mxbuild first to handle directory paths
7575 resolvedMxBuild , err := resolveMxBuild (mxbuildPath )
@@ -102,5 +102,16 @@ func resolveMx(mxbuildPath string) (string, error) {
102102 return p , nil
103103 }
104104
105+ // Try cached mxbuild installations (~/.mxcli/mxbuild/*/modeler/mx).
106+ // NOTE: lexicographic sort is imperfect for versions (e.g. "9.x" > "10.x"),
107+ // but this is a fallback-of-last-resort — in practice users typically have
108+ // only one mxbuild version installed.
109+ if home , err := os .UserHomeDir (); err == nil {
110+ matches , _ := filepath .Glob (filepath .Join (home , ".mxcli" , "mxbuild" , "*" , "modeler" , mxBinaryName ()))
111+ if len (matches ) > 0 {
112+ return matches [len (matches )- 1 ], nil
113+ }
114+ }
115+
105116 return "" , fmt .Errorf ("mx not found; specify --mxbuild-path pointing to Mendix installation directory" )
106117}
0 commit comments