-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
#Description
When working in development mode with a test site, moving a module (and its Doctypes) from one custom app to another can leave stale module references.
Even after uninstalling the old app and restarting bench, bench --site migrate fails with a ModuleNotFoundError pointing to the old app path, although the app is no longer installed.
Steps to Reproduce
- Enable developer mode.
bench set-config -g developer_mode 1
- Create a custom app:
bench new-app old_app
bench --site test.local install-app old_app
-
Create a custom module and one or more Doctypes inside old_app.
-
Create another custom app:
bench new-app new_app
bench --site test.local install-app new_app
- Move the module directory from old_app to new_app:
apps/old_app/old_app/old_module
→ apps/new_app/new_app/new_module
-
Update imports, module paths, and modules.txt accordingly.
-
Uninstall the old app:
bench --site test.local uninstall-app old_app
- Restart bench:
bench restart
-
Create a new Doctype or modify existing ones.
-
Run migrate:
bench --site test.local migrate
Expected Behavior
Migration should complete successfully.
No references to old_app should remain after uninstalling it.
Bench should not attempt to import modules from an uninstalled app.
Actual Behavior
Migration fails with an error similar to:
ModuleNotFoundError: No module named 'old_app.old_module'
The error references a path from the uninstalled app, even though:
The app is no longer installed
The module exists in the new app
Bench has been restarted
Additional Notes / Observations
This appears to be caused by stale metadata stored in:
DocType.module
tabModule Def
cached Python imports
possibly DocType.module values in the database
Manual cleanup may temporarily fix the issue:
UPDATE tabDocType
SET module = 'New Module'
WHERE module = 'Old Module';
However, this should be handled automatically during:
app uninstall
module relocation
migrate
Environment
Frappe version: 15.9
Bench version: 5.27.0
OS: Linux
Database: MariaDB
Mode: Developer mode enabled