diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index a20f3d7f36dd647d3916b2a458b605695a95894b..aeafc23a7aa58888fed293a4c5af0b0284d6971e 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -1957,7 +1957,7 @@ ModelTree::compileMEX(const string &basename, const string &funcname, const stri
           if (_NSGetExecutablePath(dynare_m_path, &size) == 0)
             {
               string str = dynare_m_path;
-              gcc_relative_path = str.substr(0, str.find_last_of("/")) + "/../../.brew/bin/gcc-11";
+              gcc_relative_path = str.substr(0, str.find_last_of("/")) + "/../.brew/bin/gcc-11";
             }
 
           if (filesystem::exists(gcc_relative_path))