Remove app and delete all its settings

When you remove an app using the button on the Apps page this deletes all the app’s files but it does not delete the apps config settings.

The occ command config:app:delete apname settingname only deletes a single setting, there doesn’t seem to be a way to delete all of an app’s settings from the system.

If an app breaks as a result of a corrupt setting this means that a simple [remove] followed by a reinstall does not solve the issue. You have to find the particular setting that is causing the problem and remove it before you can reinstall.

Since when an app is installed it sets up its default settings it seems a bit daft not to simply remove the settings when the app is uninstalled.

In the particular case that caused the problem the app itself (OnlyOffice) wrote a setting saying there was an error - this didn’t get reset by reinstalling the app and prevented the app from doing anything - you could argue that that is the app developer’s problem, but there doesn’t seem any good reason for nextcloud to leave redundant settings lying around after it removes an app - Remove is not really Removing the app, it it?

Maybe this should be posted in bugs or features - if that is more appropriate perhaps a moderator could move this topic there…

I think an issue ticket already exists which addresses this problem.

This issue isn’t even close to being solved. I have the same problem with OnlyOffice, it’s completely broken. Please someone actually address this.

@Michael_Gentles the way I had to fix OnlyOffice was to install the occ-web app (I don’t have ssh access to the server where the issue arose), and having removed both the onlyoffice connector and the document server from apps, run occ commands config:list onlyoffice to get a list of all of the settings, and then for each setting run the command config:app:delete onlyoffice settingname, and then do the same for documentserver_community.
Then I could reinstall (having removed the issue that caused the problem in the first place) and all was ok.
It can’t be that difficult to tag those commands onto the end of the remove app function wherever that is in the code. I wouldn’t have the first idea where to look.

In a related issue it would be a good feature if there was an occ command to delete all of an apps settings rather than having to type in each one individually.

1 Like

Yep, that’s almost exactly what I ended up doing just a few hours ago. The only setting I had to delete in my case was settings_error. I really wish I had fully read your initial post, I ended up finding that on my own, after pouring through the documentation. I threw my somewhat flip comment on here in frustration. I agree, it would be great if there was a way delete all of the settings. It would also be great if that settings_error wasn’t persistent even after removing the app.

delete all Settings:
sudo -u www-data php occ config:list onlyoffice

sudo -u www-data php occ config:app:delete onlyoffice DocumentServerUrl
sudo -u www-data php occ config:app:delete onlyoffice StorageUrl
sudo -u www-data php occ config:app:delete onlyoffice advanced
sudo -u www-data php occ config:app:delete onlyoffice customizationChat
sudo -u www-data php occ config:app:delete onlyoffice customizationCompactHeader
sudo -u www-data php occ config:app:delete onlyoffice customizationFeedback
sudo -u www-data php occ config:app:delete onlyoffice DocumentServerInternalUrl
sudo -u www-data php occ config:app:delete onlyoffice customizationForcesave
sudo -u www-data php occ config:app:delete onlyoffice customizationHelp
sudo -u www-data php occ config:app:delete onlyoffice customizationReviewDisplay
sudo -u www-data php occ config:app:delete onlyoffice customizationTheme
sudo -u www-data php occ config:app:delete onlyoffice customizationToolbarNoTabs
sudo -u www-data php occ config:app:delete onlyoffice customization_macros
sudo -u www-data php occ config:app:delete onlyoffice defFormats
sudo -u www-data php occ config:app:delete onlyoffice demo
sudo -u www-data php occ config:app:delete onlyoffice editFormats
sudo -u www-data php occ config:app:delete onlyoffice enabled
sudo -u www-data php occ config:app:delete onlyoffice groups
sudo -u www-data php occ config:app:delete onlyoffice installed_version
sudo -u www-data php occ config:app:delete onlyoffice jwt_secret
sudo -u www-data php occ config:app:delete onlyoffice sameTab
sudo -u www-data php occ config:app:delete onlyoffice settings_error
sudo -u www-data php occ config:app:delete onlyoffice types
sudo -u www-data php occ config:app:delete onlyoffice verify_peer_off
sudo -u www-data php occ config:app:delete onlyoffice versionHistory
sudo -u www-data php occ config:app:delete onlyoffice preview

Some help to make things lazy:

alias ncc='sudo -u www-data /usr/bin/php8.2 --define apc.enable_cli=1 /var/www/nextcloud/occ'

Iteration to delete all keys and values for a given app:

for key in $(ncc config:list | jq '.apps.cms_pico | keys[]'); do ncc config:app:delete cms_pico $key; done

Be careful using this script. Replace pico_cms as for your app.

Maybe you want make a backup before deleting:

ncc config:list pico_cms > config.pico_cms.backup