At the moment the module ships with a default install configuration. This breaks configuration management for me. I can't enable the module after it's been disabled. The easiest is to just remove the file

This is the error I got:
exception 'Drupal\Core\Config\PreExistingConfigException' with message 'Configuration objects (smtp.settings) provided by smtp already exist in active configuration'

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

miiimooo created an issue. See original summary.

miiimooo’s picture

Attach find the simple patch.

ptmkenny’s picture

Some clarification-- when you say "I can't enable the module after it's been disabled," do you mean that you can't turn the module "On" after you have turned it "Off" under Install Options at /admin/config/system/smtp?

estoyausente’s picture

Status: Active » Needs review

New D8 installation using only SMTP module.

When I try to install SMTP with web interface, the installation threw me this warning:

exception 'Drupal\Core\Config\PreExistingConfigException' with message 'Configuration objects (smtp.settings) provided by smtp already exist in  [error]
active configuration' in MYPATH/core/lib/Drupal/Core/Config/PreExistingConfigException.php:70

Applying this patch installation are ok.

I think that it is RBTC, but maybe with another review it's better.

ptmkenny’s picture

Status: Needs review » Reviewed & tested by the community

Confirming that I receive the error described in the issue without the patch, and the patch clears up the error and allows a normal install on Drupal 8.0.2 on Pantheon. RTBC.

Anonymous’s picture

fwiw, removing the default config isn't needed here, on a clean composer install + drush enable, on Drupal 8.0.3

	composer require drupal/smtp:dev-8.x-1.x
	cat config/install/smtp.settings.yml
		smtp_on: false
		smtp_host: ''
		smtp_hostbackup: ''
		smtp_port: ''
		smtp_protocol: ''
		smtp_username: ''
		smtp_password: ''
		smtp_from: ''
		smtp_fromname: ''
		smtp_allowhtml: ''
		smtp_test_address: ''
		smtp_debugging: false

	cat smtp.install
		...
		/**
		 * Implements hook_install().
		 */
		function smtp_install() {
		  // Setting default config vars.
		  \Drupal::service('config.factory')->getEditable('smtp.settings')
		    ->set('smtp_on', 0)
		    ->set('smtp_host', '')
		    ->set('smtp_hostbackup', '')
		    ->set('smtp_port', '25')
		    ->set('smtp_protocol', 'standard')
		    ->set('smtp_username', '')
		    ->set('smtp_password', '')
		    ->set('smtp_from', '')
		    ->set('smtp_fromname', '')
		    ->set('smtp_allowhtml', '')
		    ->set('smtp_test_address', '')
		    ->set('smtp_debugging', 0)
		    ->save();
		}
		...

@
BUG: Uninstall fails with ImmutableConfigException
https://www.drupal.org/node/2653338#comment-10848258

	wget https://www.drupal.org/files/issues/smtp-uninstall_fails_with-2653338-4.patch
	patch -p1 < smtp-uninstall_fails_with-2653338-4.patch

@
BUG: Invalid placeholder: !url" errors when accessing the config page
https://www.drupal.org/node/2611210

	wget https://www.drupal.org/files/issues/smtp-show_link_in_configuration_page-2611210-3-D8.patch
	patch -p1 < smtp-show_link_in_configuration_page-2611210-3-D8.patch

then

	drush -y pmu smtp
	drush cr
	drush -y en smtp

	drush cget smtp.settings
		smtp_on: false
		smtp_host: ''
		smtp_hostbackup: ''
		smtp_port: '25'
		smtp_protocol: standard
		smtp_username: ''
		smtp_password: ''
		smtp_from: ''
		smtp_fromname: ''
		smtp_allowhtml: ''
		smtp_test_address: ''
		smtp_debugging: false
		_core:
		  default_config_hash: X...X

With no errors in the install.

Settings can now be toggled at will, either at cli, e.g.

drush -y cset smtp.settings smtp_on true
drush -y cset smtp.settings smtp_on false

or in the UI.

wundo’s picture

Could anyone please confirm if this is still happening with latest DEV?

thanks

wundo’s picture

Status: Reviewed & tested by the community » Needs review
miiimooo’s picture

I think what was happening was:
* enable module
* configure
* export configuration to a staging folder
* disable module (pm-uninstall)
* enabling module gives an error because there is already configuration for it (in the staging folder)

Something like this

estoyausente’s picture

Status: Needs review » Closed (fixed)

I was installing and uninstalling the module several times (I was testing issues related with this) and I think that we can close this issue, it seems resolved.

In the las version it is resolved. @miiimooo I did the process that you describes in #9 and I didn't find any error.

Reopen it if someone can to reproduce this issue.