Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

Set current working directory (cwd) to default project root in PyPI mode

shenchucheng355ee8faa8cf
diff --git a/metagpt/const.py b/metagpt/const.py
index 47864d134..10de0ff66 100644
--- a/metagpt/const.py
+++ b/metagpt/const.py
@@ -23,6 +23,12 @@ OPTIONS = contextvars.ContextVar("OPTIONS", default={})
def get_metagpt_package_root():
"""Get the root directory of the installed package."""
package_root = Path(metagpt.__file__).parent.parent
+ for i in (".git", ".project_root", ".gitignore"):
+ if (package_root / i).exists():
+ break
+ else:
+ package_root = Path.cwd()
+
logger.info(f"Package root set to {str(package_root)}")
return package_root