{"record":{"id":"15857fb2e5ba9bd0","repo":"reflex-dev/reflex","slug":"file-not-found-src-file-shared","errorCode":null,"errorMessage":"File not found: {src_file_shared}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"reflex/assets.py","lineNumber":277,"sourceCode":"            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\n    caller_module_path = module.__name__.replace(\".\", \"/\")\n    subfolder = f\"{caller_module_path}/{subfolder}\" if subfolder else caller_module_path\n\n    # Symlink the asset to the app's external assets directory if running frontend.\n    if not backend_only:\n        # Create the asset folder in the currently compiling app.\n        asset_folder = Path.cwd() / assets / external / subfolder\n        asset_folder.mkdir(parents=True, exist_ok=True)\n\n        dst_file = asset_folder / path\n\n        if not dst_file.exists() and (\n            not dst_file.is_symlink() or dst_file.resolve() != src_file_shared.resolve()\n        ):\n            try:\n                dst_file.symlink_to(src_file_shared)\n            except FileExistsError:","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/assets.py#L259-L295","documentation":"Raised by rx.asset() for shared assets (@pkg:...) when the file cannot be found relative to the calling module's file (Path(calling_file).parent / path). Reflex resolves shared assets from the source module's directory so they can be symlinked into the app's external assets directory; a missing file aborts that.","triggerScenarios":"Using rx.asset('/@pkg:somepkg/path/file.css') where somepkg does not actually ship that file at that path, or where the calling module's __file__ location makes the joined path wrong. Triggered during page render / app creation when favicons_links or index call into asset().","commonSituations":"Upgrading a component library whose asset layout changed (path moved/renamed); typo in the @pkg: sub-path; package installed without its data files (broken wheel or MANIFEST exclusion); namespace/relative import edge cases where calling_file resolution is off.","solutions":["Check the installed package on disk (site-packages) to confirm the actual asset path and correct the rx.asset call","Pin or upgrade/downgrade the component package to a version that ships the file at the path you reference","If the asset is yours, move it next to the calling module or reference it as a local asset instead","Reinstall the package if its data files were excluded from the wheel"],"exampleFix":"// before\nrx.color_mode.button(style=rx.asset(\"/@pkg:my_lib/button.css\"))\n// after\nrx.color_mode.button(style=rx.asset(\"/@pkg:my_lib/styles/button.css\"))  # actual shipped path","handlingStrategy":"validation","validationCode":"from pathlib import Path\nimport reflex as rx\n\ndef shared_asset(pkg_path: str) -> str:\n    # pkg_path like '/@pkg:somepkg/file.css'\n    _, spec = pkg_path.split(\":\", 1)\n    mod, _, rel = spec.partition(\"/\")\n    import importlib, reflex as _rx\n    base = Path(importlib.import_module(mod).__file__).parent\n    if not (base / rel).exists():\n        raise FileNotFoundError(f\"{pkg_path} not shipped by {mod}\")\n    return rx.asset(pkg_path)","typeGuard":null,"tryCatchPattern":"try:\n    href = rx.asset(\"/@pkg:my_lib/button.css\")\nexcept FileNotFoundError:\n    href = rx.asset(\"/button.css\")  # local fallback","preventionTips":["Verify shipped asset paths inside site-packages after upgrading component packages","Pin component package versions in CI","Prefer local assets for one-off files to avoid package-layout coupling"],"tags":["reflex","assets","shared-assets","package-files"],"backgroundTag":"file-not-found","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}