We get this error when try to install the module:

"Unable to install File entity, core.entity_view_mode.file.thumbnail already exists in active configuration."

How to reproduce

  1. Install the module
  2. Un-install the module
  3. Install the module again
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joco_sp created an issue. See original summary.

jfcolomer’s picture

I had the same issue, this worked for me:
https://www.drupal.org/node/2670594#comment-10901180

Berdir’s picture

The config entity should either be moved to optional config or have a enforced dependency.

That said, why would you want to re-install file_entity like that?

grahl’s picture

Attached is a trivial patch moving the file to optional.

I'm not sure the core update is actually a necessary step and uninstalling and reinstalling might already be sufficient to trigger it. I don't have the time to test that cleanly at the moment, sorry.

otarza’s picture

I can confirm that this also happens when you already have core.entity_view_mode.file.thumbnail config in your site and you try to install `file_entity` module.

otarza’s picture

I can confirm that #4 patch works.

otarza’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: can_t_reenable_module-2715173-4.patch, failed testing.

The last submitted patch, 4: can_t_reenable_module-2715173-4.patch, failed testing.

claudiu.cristea’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: can_t_reenable_module-2715173-4.patch, failed testing.

The last submitted patch, 4: can_t_reenable_module-2715173-4.patch, failed testing.

Berdir’s picture

The tests show why this doesn't work. Other config depends on this, you can't move only those to optional, you have to move everything that depends on it.

piyuesh23’s picture

Why don't we consider deleting the config created as a part of install process in the uninstall hook here? I think the problem here is not related to missing dependencies, but a config left in the site while un-installing the module & the install process trying to create the same again.

  // Now delete all of the configuration installed by this module.
  $dir = drupal_get_path('module', 'file_entity') . '/config/install';
  $files = file_scan_directory($dir, '/.*/');
  foreach ($files as $file) {
    \Drupal::configFactory()->getEditable($file->name)->delete();
  }
  \Drupal::logger('file_entity')->info(t('Deleted file_entity configuration.'), array());
oriol_e9g’s picture

An easy fast fix can be:

  1. Open MySQL and execute: DELETE FROM YOUR_PREFIX_config WHERE name = 'core.entity_view_mode.file.thumbnail'
  2. Clear cache
  3. Install again
oriol_e9g’s picture

Title: Can't reenable module after updating core to 8.1.0 » I can't re-install the module after uninstalling
Status: Needs work » Needs review
FileSize
492 bytes

Why not enforce this configuration?

How to reproduce the error:

  1. Install the module
  2. Un-install the module
  3. Install the module again
oriol_e9g’s picture

Issue summary: View changes
jian he’s picture

Status: Needs review » Reviewed & tested by the community

#16 looks good for me.

mausolos’s picture

Btw, I was able to workaround this issue by doing:

  • drush config-list | grep thumbnail (to confirm it's indeed there)
  • drush config-delete core.entity_view_mode.file.thumbnail
  • drush pm-enable file_entity
  • drush config-list | grep thumbnail (to confirm it was restored)

Of course, then when I went to uninstall, I got the error:

Drupal\Core\Field\FieldException: Attempt to create a field field_image_alt_text that does not exist on entity type  [error]
file. in /apps/drupal/d8root/core/modules/field/src/Entity/FieldConfig.php:293

Soooooo...
I ran drush entity-updates. More errors:

$ drush entity-updates
The following updates are pending:

file entity type :
  The File type field needs to be updated.
Do you wish to run all pending updates? (y/n): y
Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. SQLSTATE[42S22]: Column[error]
not found: 1054 Unknown column 'type' in 'where clause': SELECT 1 AS expression
FROM
{file_managed} t
WHERE type IS NOT NULL
LIMIT 1 OFFSET 0; Array
(
)
 in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1513 of
/apps/drupal/d8root/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Failed: Drupal\Core\Entity\EntityStorageException: !message in                                                       [error]
Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1513 of
/apps/drupal/d8root/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Cache rebuild complete.                                                                                              [ok]
Finished performing updates.

Hmm.. did that do the trick, though?

$ drush pm-uninstall file_entity
The following extensions will be uninstalled: file_entity
Do you really want to continue? (y/n): y
file_entity was successfully uninstalled. 

From this point on, the behavior is predictable and just goes in a circle. FYI, but I can't speak to how solid this approach is.

oriol_e9g’s picture

The easiest solution is use the module with the patch in #16 while we wait the commit. You can add the patch in composer.json to ensure that always install or update the module with the patch applied.

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed
websiteworkspace’s picture

This problem actually persists in the current version after updating to Drupal 8.4.2.

Neither running drush entup or drupal update:entities fixes this problem.

(see also)
https://www.drupal.org/project/file_entity/issues/2914935

websiteworkspace’s picture

Status: Fixed » Active
oriol_e9g’s picture

@websiteworkspace you need to use the dev version of File Entity (fieldable files) module, upgrade drupal core will do nothing.

websiteworkspace’s picture

@oriol_e9g ...

Please note ...

It has been possible to fix the problem by issuing the following SQL commands on the database:




alter table file_managed modify `type` varchar(32) CHARACTER SET ascii NOT NULL COMMENT 'The ID of the target entity.';

update key_value set value = replace (value, '"not null";b:0', '"not null";b:1') where name="file.field_schema_data.type";



The update to 8.4.2 WAS NOT an attempt to "fix" the problem.
The update of core to 8.4.2 preceded the problem's appearance and is was what precipitated the problem described.

It isn't reasonable to be running the dev branch module on the site in any event.
Furthermore its module versioning is all managed by composer, and a dev branch of that isn't warranted.

anyway ...
the problem is now fixed.

Meanwhile, it seems like the maintainers of the module should complete necessary testing of their fix and role that fix into a release version of the module, rather than suggesting that site's run a dev branch version.

Berdir’s picture

Status: Active » Fixed

What you are describing is about the issue you yourself linked/mentioned above, not *this*. This was just about config not being removed that prevented a re-install.

The maintainers are mostly using their free time to maintain this project and help people like you, there really is no need to rant about what we should or shouldn't do. You're welcome to help by providing and reviewing patches and supporting others. Also keep in mind that you are using a beta version, in the end, there's not much difference between using a beta version and dev.

And you can for example pin composer to a specific commit of a dev version, it's absolutely possible to use dev versions with composer.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

MartinMa’s picture

I just wanted to install filde download tracker. Got the error message "It was not possible to install File entity. core.entity_view_mode.file.thumbnail already exists in the active configuration." too.

Removed core.entity_view_mode.file.thumbnail in SQL database

On second attempt to install got "fatal error"

But on third run it worked.

Long time ago I had file entity installed. Hope problem has gone now.