reflex-dev/reflex · error · FileNotFoundError
The stylesheet file {stylesheet_full_path} does not exist.
Error message
The stylesheet file {stylesheet_full_path} does not exist. What it means
Each non-URL stylesheet listed in add_styles must exist under the app's assets directory at compile time; Reflex needs to read (and for directories, rglob) the file(s) to inline them into the compiled root stylesheet. A missing file raises FileNotFoundError.
Source
Thrown at reflex/compiler/compiler.py:365
active_plugins = get_config().plugins if plugins is None else plugins
sheets.extend([
sheet for plugin in active_plugins for sheet in plugin.get_stylesheet_paths()
])
failed_to_import_sass = False
assets_app_path = Path.cwd() / constants.Dirs.APP_ASSETS
stylesheets_files: list[Path] = []
stylesheets_urls = []
for stylesheet in stylesheets:
if not utils.is_valid_url(stylesheet):
# check if stylesheet provided exists.
stylesheet_full_path = assets_app_path / stylesheet.strip("/")
if not stylesheet_full_path.exists():
msg = f"The stylesheet file {stylesheet_full_path} does not exist."
raise FileNotFoundError(msg)
if stylesheet_full_path.is_dir():
all_files = (
file
for ext in constants.Reflex.STYLESHEETS_SUPPORTED
for file in stylesheet_full_path.rglob("*." + ext)
)
for file in all_files:
if file.is_dir():
continue
# Validate the stylesheet.
_validate_stylesheet(file, assets_app_path)
stylesheets_files.append(file)
else:
# Validate the stylesheet.
_validate_stylesheet(stylesheet_full_path, assets_app_path)
stylesheets_files.append(stylesheet_full_path)View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Create or commit the file at the exact path shown in the error message
- Correct the path/subdirectory in the add_styles entry
- Check .gitignore rules if the file exists locally but fails in CI/other checkouts
Example fix
# before app = rx.App(add_styles=["/css/theme.css"]) # file actually at assets/styles/theme.css # after app = rx.App(add_styles=["/styles/theme.css"])
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
def validate_stylesheet_files(styles: list[str], assets_dir: Path) -> list[str]:
for s in styles:
if s.startswith(("http://", "https://")):
continue
p = assets_dir / s.strip("/")
if not p.exists():
raise FileNotFoundError(f"stylesheet not found: {p}")
return styles
app = rx.App(add_styles=validate_stylesheet_files(my_styles, Path(".web/assets"))) Prevention
- Add a smoke test that asserts every add_styles entry exists under assets/
- Don't gitignore *.css in the assets directory
- Double-check case and subdirectory of each stylesheet path
When it happens
Trigger: rx.App(add_styles=["/css/theme.css"]) where assets/css/theme.css does not exist — typo'd name, wrong subdirectory, or file never committed. Also triggered when a directory entry matches no supported stylesheet files inside it.
Common situations: Renaming/moving CSS files without updating App config; assets excluded by .gitignore so teammates/CI hit it; case-mismatch of the filename across operating systems.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Stylesheet file {stylesheet_full_path} is not supported.
- Cannot include stylesheets from outside the assets directory
- Stylesheet file name cannot be '{PageNames.STYLESHEET_ROOT}'
- File not found: {src_file_local}
- Stylesheet file name cannot be empty: {stylesheet_full_path}
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/d12982bf8460e28b.
Report an issue: GitHub.