Unable to remove app s3_frappe_attachment

while uninstalling s3_frappe_attachment

using cmd - bench uninstall-app frappe_s3_attachment

getting error -

➜  procurement_app git:(develop) ✗ bench uninstall-app frappe_s3_attachment

Could not find app "frappe_s3_attachment": 
No module named 'frappe_s3_attachment'
Traceback (most recent call last):
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/utils/caching.py", line 57, in wrapper
    return frappe.local.request_cache[func][args_key]
KeyError: 4414699422777896185

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 128, in <module>
    main()
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 34, in main
    FrappeCommandGroup(commands=commands)(prog_name="bench")
  File "/Users/DeHaat/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/DeHaat/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/DeHaat/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/DeHaat/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/DeHaat/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/DeHaat/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/DeHaat/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/commands/site.py", line 1024, in uninstall
    remove_app(app_name=app, dry_run=dry_run, yes=yes, no_backup=no_backup, force=force)
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/installer.py", line 367, in remove_app
    app_hooks = frappe.get_hooks(app_name=app_name)
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/__init__.py", line 1677, in get_hooks
    hooks = _dict(_load_app_hooks(app_name))
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/utils/caching.py", line 59, in wrapper
    return_val = func(*args, **kwargs)
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/__init__.py", line 1649, in _load_app_hooks
    app_hooks = get_module(f"{app}.hooks")
  File "/Users/DeHaat/frappe-bench/apps/frappe/frappe/__init__.py", line 1514, in get_module
    return importlib.import_module(modulename)
  File "/usr/local/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'frappe_s3_attachment'

Hi, @ahsas5

Go to your Frappe-bench

Check Installed Apps:
 bench list-apps

Remove App from Sites
If the app is not listed but you still want to remove it, you can manually remove it from your site’s configuration

 Open the sites/site_name/site_config.json file.
 Remove the app name from the installed_apps list.

 bench clear-cache

Remove App Directory
rm -rf apps/frappe_s3_attachment

Same error, post doing above things.

Check for Database Entries: If the app was installed but the directory is missing, there might still be references in the database. You can manually remove entries related to the frappe_s3_attachment app. Access the MariaDB console for your site:

bench --site [site-name] mariadb

Once in the MariaDB console, remove entries related to frappe_s3_attachment from the tabInstalled Applications table

DELETE FROM tabInstalled Applications WHERE app_name=‘frappe_s3_attachment’;

bench uninstall-app frappe_s3_attachment

Check for Custom Scripts: Ensure there are no custom scripts or settings that reference the frappe_s3_attachment module. Sometimes, custom scripts or custom fields might still reference the module, causing errors during uninstallation.

No record of s3_frappe_attachment in DB.

also directory is also not present

Same issue.

Check sites/apps.txt: Ensure that frappe_s3_attachment is not listed in your sites/apps.txt file. If it is, remove it:

    nano ~/frappe-bench/sites/apps.txt

Remove from apps.json: Sometimes, the app may be listed in the apps.json file in your site’s directory. Check and remove it if necessary:

nano ~/frappe-bench/sites/[your-site]/apps.json

bench clear-cache
bench clear-website-cache

update Site Configuration: Make sure the site configuration does not include the app. Open the site configuration file and ensure frappe_s3_attachment is not listed under installed apps:

nano ~/frappe-bench/sites/[your-site]/site_config.jso

bench restart

Here is the script