From 7f0fb4175213b3e50ece82aa6db4079eee08edfa Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Tue, 14 May 2024 17:01:28 -0700 Subject: [PATCH] REFLEX_USE_NPM escape hatch to opt out of bun In some unsupported environments, we need to just not use bun. Further investigation needed. --- reflex/utils/prerequisites.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index e33f1ea81..cd4739c44 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -185,6 +185,7 @@ def get_install_package_manager() -> str | None: constants.IS_WINDOWS and not is_windows_bun_supported() or windows_check_onedrive_in_path() + or windows_npm_escape_hatch() ): return get_package_manager() return get_config().bun_path @@ -212,6 +213,15 @@ def windows_check_onedrive_in_path() -> bool: return "onedrive" in str(Path.cwd()).lower() +def windows_npm_escape_hatch() -> bool: + """For windows, if the user sets REFLEX_USE_NPM, use npm instead of bun. + + Returns: + If the user has set REFLEX_USE_NPM. + """ + return os.environ.get("REFLEX_USE_NPM", "").lower() in ["true", "1", "yes"] + + def get_app(reload: bool = False) -> ModuleType: """Get the app module based on the default config.