Is it possible to import one single yml configuration file by specifying its path?

Or a group of yml files contained in a specific module?

  • You can by enabling the config module and then using the single import page. – user21641 Nov 28 '16 at 9:11
  • Thanks @IvanJaros, can you expand the comment to an answer with details how to enable the config module and the path to the single import page? Is there any way to achieve the same results with drush or drupal console? If it works, I'll accept the answer. Cheers! – David Riccitelli Nov 28 '16 at 9:37
  • i guess you can put the file into config/sync directory and just run drush cim, ive always used ui for single config file. – user21641 Nov 28 '16 at 9:42
  • That would import all the files in the sync directory. – David Riccitelli Nov 28 '16 at 12:40

You can use

$ drush cim --partial --source=only-few-configs/

Your help says:

$ drush cim --help
Import config from a config directory.

 drush config-import --partial             Import configuration; do not remove missing configuration.

 label                                     A config directory label (i.e. a key in $config_directories array in 
                                           settings.php). Defaults to 'sync'

 --partial                                 Allows for partial config imports from the source directory. Only updates and new 
                                           configs will be processed with this flag (missing configs will not be deleted).   
 --preview=<list>                          Format for displaying proposed changes. Recognized values: list, diff. Defaults   
                                           to list.                                                                          
 --source                                  An arbitrary directory that holds the configuration files. An alternative to      
                                           label argument

Aliases: cim
| improve this answer | |
  • 4
    That's great, but if you want to import one file you have to move it to another partial directory? That's weird, isn't it? – rreiss Jul 24 '18 at 7:53
  • If running in Lando/Docker, prefix the directory path with /app/ (as suggested in the Drupal Console answer). – colan Apr 21 at 16:37

You can import one configuration by running the following command:

 drupal config:import:single

If you are trying to run multiple import you can create a chain for that.

Command Documentation - config:import:single

| improve this answer | |
  • 4
    Is there an option for drush aswell? – Benedikt Oct 16 '17 at 7:10
  • 7
    Tip for Lando/Docker users - you need to specify the full path when running in a container, e.g. drupal config:import:single --directory="/app/config/sync" --file="foo.settings.yml", rather than just config/sync when you are in /app - otherwise you'll get [ERROR] Value can not be empty. (Fortunately Drupal Console's source code is nice and easy to debug.) – William Turrell Jul 25 '18 at 5:55

In case you don't have Drush or Drupal console installed, please use the following steps (executed successfully in D 8.0.1):

  1. Go to Administration->Configuration->Configuration Synchronization. Configuration can be exported for a single item or for entire site. I did for a single user.mail.yml file. Export the required configuration.
    1. Modify the changes to the exported configuration.
    2. Import the modified configuration
    3. Once import is successful, ensure that you clear the existing data from config and cache_config tables(Extract a dump of the database and search for the configuration keywords. That way you will know the tables where the entry is present.)

Note - Always take a backup.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.