drupal-graphql / drupal-decoupled-app

Decoupled Drupal demo application based on React, GraphQL and Apollo including server-side rendering.
MIT License
311 stars 76 forks source link

drush si config_installer fails: file_put_contents(sites/default/settings.php): failed to open stream: Permission denied install.inc:337 #390

Closed ghost closed 6 years ago

ghost commented 7 years ago

When I run drush si config_installer inside the container, it fails with a permission error. I followed the "Usage" instructions in the readme. All files (including sites/default/settings.php) are owned by my user id and group id and have -rwxrwxr-x permissions, while the container runs as uid 1000. I cannot work around this by specifying a different --user option to docker-compose exec, as only the drupal user (uid 1000) has access to the Drupal directory /var/www/drupal/.

$ docker-compose exec --user drupal drupal bash
🐳 drupal@decoupled.backend.docker.amazee.io:~/public_html/backend/web (master *=)$ drush si config_installer -y --account-name=admin --account-pass=admin
You are about to DROP all tables in your 'drupal' database. Do you want to continue? (y/n): y
Starting Drupal installation. This takes a while. Consider using the --notify global option.                                                                                                                                                                          [ok]
file_put_contents(sites/default/settings.php): failed to open stream: Permission denied install.inc:337                                                                                                                                                               [warning]
Exception: Failed to modify <em class="placeholder">sites/default/settings.php</em>. Verify the file permissions. in /var/www/drupal/public_html/backend/web/core/includes/install.inc:338                                                                            [error]
Stack trace:
#0 /var/www/drupal/public_html/backend/web/profiles/contrib/config_installer/src/Form/SiteConfigureForm.php(121): drupal_rewrite_settings(Array)
#1 [internal function]: Drupal\config_installer\Form\SiteConfigureForm->buildForm(Array, Object(Drupal\Core\Form\FormState), Array)
#2 /var/www/drupal/public_html/backend/web/core/lib/Drupal/Core/Form/FormBuilder.php(514): call_user_func_array(Array, Array)
#3 /var/www/drupal/public_html/backend/web/core/lib/Drupal/Core/Form/FormBuilder.php(472): Drupal\Core\Form\FormBuilder->retrieveForm('config_installe...', Object(Drupal\Core\Form\FormState))
#4 /var/www/drupal/public_html/backend/web/core/includes/install.core.inc(909): Drupal\Core\Form\FormBuilder->submitForm('Drupal\\config_i...', Object(Drupal\Core\Form\FormState))
#5 /var/www/drupal/public_html/backend/web/core/includes/install.core.inc(584): install_get_form('Drupal\\config_i...', Array)
#6 /var/www/drupal/public_html/backend/web/core/includes/install.core.inc(540): install_run_task(Array, Array)
#7 /var/www/drupal/public_html/backend/web/core/includes/install.core.inc(117): install_run_tasks(Array)
#8 /var/www/drupal/public_html/backend/vendor/drush/drush/includes/drush.inc(726): install_drupal(Object(Composer\Autoload\ClassLoader), Array)
#9 /var/www/drupal/public_html/backend/vendor/drush/drush/includes/drush.inc(711): drush_call_user_func_array('install_drupal', Array)
#10 /var/www/drupal/public_html/backend/vendor/drush/drush/commands/core/drupal/site_install.inc(82): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array)
#11 /var/www/drupal/public_html/backend/vendor/drush/drush/commands/core/site_install.drush.inc(255): drush_core_site_install_version('config_installe...', Array)
#12 /var/www/drupal/public_html/backend/vendor/drush/drush/includes/command.inc(422): drush_core_site_install('config_installe...')
#13 /var/www/drupal/public_html/backend/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#14 /var/www/drupal/public_html/backend/vendor/drush/drush/includes/command.inc(199): drush_command('config_installe...')
#15 /var/www/drupal/public_html/backend/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#16 /var/www/drupal/public_html/backend/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#17 /var/www/drupal/public_html/backend/vendor/drush/drush/drush.php(12): drush_main()
#18 {main}
fubhy commented 6 years ago

Sounds like you installed Druipal before once and are ttrying to reinstall now. In that case, you need to set the permissions of the settings.php file back to writable on the host system so the installer can touch it.