better missing system package message
This commit is contained in:
parent
1c4f410052
commit
5168d8164e
@ -5,6 +5,8 @@ from .base import (
|
|||||||
ENV_BACKEND_ONLY_ENV_VAR,
|
ENV_BACKEND_ONLY_ENV_VAR,
|
||||||
ENV_FRONTEND_ONLY_ENV_VAR,
|
ENV_FRONTEND_ONLY_ENV_VAR,
|
||||||
ENV_MODE_ENV_VAR,
|
ENV_MODE_ENV_VAR,
|
||||||
|
IS_LINUX,
|
||||||
|
IS_MACOS,
|
||||||
IS_WINDOWS,
|
IS_WINDOWS,
|
||||||
LOCAL_STORAGE,
|
LOCAL_STORAGE,
|
||||||
POLLING_MAX_HTTP_BUFFER_SIZE,
|
POLLING_MAX_HTTP_BUFFER_SIZE,
|
||||||
|
@ -13,6 +13,8 @@ from platformdirs import PlatformDirs
|
|||||||
from .utils import classproperty
|
from .utils import classproperty
|
||||||
|
|
||||||
IS_WINDOWS = platform.system() == "Windows"
|
IS_WINDOWS = platform.system() == "Windows"
|
||||||
|
IS_MACOS = platform.system() == "Darwin"
|
||||||
|
IS_LINUX = platform.system() == "Linux"
|
||||||
|
|
||||||
|
|
||||||
class Dirs(SimpleNamespace):
|
class Dirs(SimpleNamespace):
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""Custom Exceptions."""
|
"""Custom Exceptions."""
|
||||||
|
|
||||||
|
from typing import NoReturn
|
||||||
|
|
||||||
|
|
||||||
class ReflexError(Exception):
|
class ReflexError(Exception):
|
||||||
"""Base exception for all Reflex exceptions."""
|
"""Base exception for all Reflex exceptions."""
|
||||||
@ -151,3 +153,25 @@ class DynamicComponentInvalidSignature(ReflexError, TypeError):
|
|||||||
|
|
||||||
class InvalidPropValueError(ReflexError):
|
class InvalidPropValueError(ReflexError):
|
||||||
"""Raised when a prop value is invalid."""
|
"""Raised when a prop value is invalid."""
|
||||||
|
|
||||||
|
|
||||||
|
class SystemPackageMissingError(ReflexError):
|
||||||
|
"""Raised when a system package is missing."""
|
||||||
|
|
||||||
|
|
||||||
|
def raise_system_package_missing_error(package: str) -> NoReturn:
|
||||||
|
"""Raise a SystemPackageMissingError.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
package: The name of the missing system package.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
SystemPackageMissingError: The raised exception.
|
||||||
|
"""
|
||||||
|
from reflex.constants import IS_MACOS
|
||||||
|
|
||||||
|
raise SystemPackageMissingError(
|
||||||
|
f"System package '{package}' is missing."
|
||||||
|
" Please install it through your system package manager."
|
||||||
|
+ (f" You can do so by running 'brew install {package}'." if IS_MACOS else "")
|
||||||
|
)
|
||||||
|
@ -35,7 +35,10 @@ from reflex import constants, model
|
|||||||
from reflex.compiler import templates
|
from reflex.compiler import templates
|
||||||
from reflex.config import Config, environment, get_config
|
from reflex.config import Config, environment, get_config
|
||||||
from reflex.utils import console, net, path_ops, processes
|
from reflex.utils import console, net, path_ops, processes
|
||||||
from reflex.utils.exceptions import GeneratedCodeHasNoFunctionDefs
|
from reflex.utils.exceptions import (
|
||||||
|
GeneratedCodeHasNoFunctionDefs,
|
||||||
|
raise_system_package_missing_error,
|
||||||
|
)
|
||||||
from reflex.utils.format import format_library_name
|
from reflex.utils.format import format_library_name
|
||||||
from reflex.utils.registry import _get_npm_registry
|
from reflex.utils.registry import _get_npm_registry
|
||||||
|
|
||||||
@ -820,11 +823,7 @@ def install_node():
|
|||||||
|
|
||||||
|
|
||||||
def install_bun():
|
def install_bun():
|
||||||
"""Install bun onto the user's system.
|
"""Install bun onto the user's system."""
|
||||||
|
|
||||||
Raises:
|
|
||||||
FileNotFoundError: If required packages are not found.
|
|
||||||
"""
|
|
||||||
win_supported = is_windows_bun_supported()
|
win_supported = is_windows_bun_supported()
|
||||||
one_drive_in_path = windows_check_onedrive_in_path()
|
one_drive_in_path = windows_check_onedrive_in_path()
|
||||||
if constants.IS_WINDOWS and not win_supported or one_drive_in_path:
|
if constants.IS_WINDOWS and not win_supported or one_drive_in_path:
|
||||||
@ -863,7 +862,7 @@ def install_bun():
|
|||||||
else:
|
else:
|
||||||
unzip_path = path_ops.which("unzip")
|
unzip_path = path_ops.which("unzip")
|
||||||
if unzip_path is None:
|
if unzip_path is None:
|
||||||
raise FileNotFoundError("Reflex requires unzip to be installed.")
|
raise_system_package_missing_error("unzip")
|
||||||
|
|
||||||
# Run the bun install script.
|
# Run the bun install script.
|
||||||
download_and_run(
|
download_and_run(
|
||||||
|
Loading…
Reference in New Issue
Block a user