From d00425276d5025720e45e12f3a58c0a83fa5420b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Brand=C3=A9ho?= Date: Mon, 23 Oct 2023 17:45:55 +0200 Subject: [PATCH] fix fnm version check (#2014) --- reflex/utils/exec.py | 4 ++-- reflex/utils/prerequisites.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/reflex/utils/exec.py b/reflex/utils/exec.py index 9e53472924..38a9599177 100644 --- a/reflex/utils/exec.py +++ b/reflex/utils/exec.py @@ -247,13 +247,13 @@ def output_system_info(): if system != "Windows": dependencies.extend( [ - f"[FNM {constants.Fnm.VERSION} (Expected: {constants.Fnm.VERSION}) (PATH: {constants.Fnm.EXE})]", + f"[FNM {prerequisites.get_fnm_version()} (Expected: {constants.Fnm.VERSION}) (PATH: {constants.Fnm.EXE})]", f"[Bun {prerequisites.get_bun_version()} (Expected: {constants.Bun.VERSION}) (PATH: {config.bun_path})]", ], ) else: dependencies.append( - f"[FNM {constants.Fnm.VERSION} (Expected: {constants.Fnm.VERSION}) (PATH: {constants.Fnm.EXE})]", + f"[FNM {prerequisites.get_fnm_version()} (Expected: {constants.Fnm.VERSION}) (PATH: {constants.Fnm.EXE})]", ) if system == "Linux": diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 6852850694..9b558390bc 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -60,6 +60,19 @@ def get_node_version() -> version.Version | None: return None +def get_fnm_version() -> version.Version | None: + """Get the version of fnm. + + Returns: + The version of FNM. + """ + try: + result = processes.new_process([constants.Fnm.EXE, "--version"], run=True) + return version.parse(result.stdout.split(" ")[1]) # type: ignore + except (FileNotFoundError, TypeError): + return None + + def get_bun_version() -> version.Version | None: """Get the version of bun.