You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Kept env.py failure: the "move it aside" hint is dropped and a full traceback is logged when alembic.ini uses a relative script_location #7856
#7809 made a failing hand-edited alembic/env.py report a one-line error with the fix ("…move it aside and run reflex db init to write the current template") and move the traceback to the debug log, but only when env.py itself raised. That check never matches when alembic.ini has a relative script_location = alembic. The hint is then dropped and the full traceback (~45 lines) is logged at ERROR on every reflex db command and at app startup.
The relative form is what older alembic versions wrote, so it is common in exactly the long-lived apps a kept env.py comes from (for example reflex-examples form-designer and chat_v2). reflex db init with current alembic writes %(here)s/alembic, which works.
Messaging only: exit codes and app start-up are correct, and the separate once-per-process "env.py is not the Reflex template … Move it aside and run reflex db init" warning still appears.
Repro (reflex 0.11.0a2)
reflex init --template blank, add db_url to rxconfig, reflex db init.
Replace alembic/env.py with raise RuntimeError("boom").
In alembic.ini set script_location = alembic (relative).
reflex db status.
script_location
rc
hint shown
traceback lines at ERROR
%(here)s/alembic
1
yes
0
alembic
1
no
15
Cause
reflex/utils/migrations.py: script_directory() returns Path(ScriptDirectory.from_config(config).dir), which is relative (Path("alembic")) for a relative script_location. _raised_in_env_py() compares it with absolute traceback filenames via path.is_relative_to(scripts), which is never true, so it returns False.
Fix
Resolve both sides before comparing: scripts = script_directory().resolve() and Path(filename).resolve() for each frame (and for SyntaxError.filename). Alternatively make script_directory() return an absolute path resolved against the alembic.ini directory, which also fixes the relative path printed in the "kept as alembic/env.old" message.
Regression test in tests/units/utils/test_migrations.py: the existing custom-env failure test, parametrized over script_location = %(here)s/alembic and script_location = alembic, asserting the hint is present and exc_info is not logged at ERROR in both.
Activity
linear-code commentedon Nov 11, 2026
ENG-14005