{"record":{"id":"66571ae7527c4724","repo":"reflex-dev/reflex","slug":"file-not-found-src-file-local","errorCode":null,"errorMessage":"File not found: {src_file_local}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"reflex/assets.py","lineNumber":260,"sourceCode":"        for use as a build-time module reference.\n\n    Raises:\n        FileNotFoundError: If the file does not exist.\n        ValueError: If subfolder is provided for local assets.\n    \"\"\"\n    assets = constants.Dirs.APP_ASSETS\n    backend_only = EnvironmentVariables.REFLEX_BACKEND_ONLY.get()\n\n    # Local asset handling\n    if not shared:\n        cwd = Path.cwd()\n        src_file_local = cwd / assets / path\n        if subfolder is not None:\n            msg = \"Subfolder is not supported for local assets.\"\n            raise ValueError(msg)\n        if not backend_only and not src_file_local.exists():\n            msg = f\"File not found: {src_file_local}\"\n            raise FileNotFoundError(msg)\n        relative_path = f\"/{path}\"\n        if backend_only and not src_file_local.exists():\n            return AssetPathStr(relative_path)\n        return _versioned_asset_path(relative_path, src_file_local)\n\n    # Shared asset handling\n    # Determine the file by which the asset is exposed.\n    frame = inspect.stack()[_stack_level]\n    calling_file = frame.filename\n    module = inspect.getmodule(frame[0])\n    assert module is not None\n\n    external = constants.Dirs.EXTERNAL_APP_ASSETS\n    src_file_shared = Path(calling_file).parent / path\n    if not src_file_shared.exists():\n        msg = f\"File not found: {src_file_shared}\"\n        raise FileNotFoundError(msg)\n","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/assets.py#L242-L278","documentation":"Raised by rx.asset() when the given local asset path does not exist on disk relative to the working directory (cwd / assets / path). Reflex requires local assets to physically exist so it can copy/symlink and version them into the app's assets directory. The check is skipped only when backend_only is true.","triggerScenarios":"Calling rx.asset('/myfile.png') (or a path without leading slash) where no such file exists under <project>/.web/assets (or the configured assets dir). Happens for local paths only, since http(s):// URLs and shared (@pkg:style) paths take other branches. Also raised when the working directory during import is not the project root, making the resolved relative path wrong.","commonSituations":"Typos in the asset path; asset file not committed/pulled with the repo (gitignore excludes); running the app from a different cwd so relative resolution fails; case-sensitivity mismatch of the filename (developed on macOS/Linux, deployed on a case-sensitive fs or vice versa).","solutions":["Verify the file exists at the printed path and fix the typo or case in rx.asset(...)","If the asset lives in another package, use the shared-asset syntax rx.asset('/@pkg:pkgname/style.css') or put the file under your app's assets directory","Ensure the process cwd is the project root (or pass a path valid from the current cwd)","If you intentionally reference a backend-only file that may not exist yet, pass backend_only=True and handle the returned unversioned path"],"exampleFix":"// before\nrx.image(src=rx.asset(\"/logo.png\"))  # FileNotFoundError: File not found: .../assets/logo.png\n// after\nrx.image(src=rx.asset(\"/logo.png\"))  # after adding logo.png to <project>/assets/","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef safe_asset(path: str, **kwargs):\n    import reflex as rx\n    if not path.startswith((\"http://\", \"https://\", \"/@pkg:\")):\n        local = Path.cwd() / \".web\" / \"assets\" / path.lstrip(\"/\")\n        if not local.exists():\n            raise FileNotFoundError(f\"missing asset: {local}\")\n    return rx.asset(path, **kwargs)","typeGuard":null,"tryCatchPattern":"try:\n    src = rx.asset(\"/logo.png\")\nexcept FileNotFoundError as e:\n    log.warning(f\"asset missing, falling back: {e}\")\n    src = \"/favicon.ico\"","preventionTips":["Keep all local assets under the project assets/ directory and reference them with leading-slash paths","Add a startup assertion listing required asset files","Commit assets to version control and check .gitignore rules"],"tags":["reflex","assets","file-not-found","static-files"],"backgroundTag":"file-not-found","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}