Problem/Motivation
When installing with a Drupal site which has it's database connection predefined for SQLite (and maybe without), the Drupal site crashes due to the file_system service not being available
<br />
<b>Fatal error</b>: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "file_system". in /persist/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php:992
Stack trace:
#0 /persist/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(568): Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition('file_system')
#1 /persist/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php(531): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('file_system', 1)
#2 /persist/drupal/web/core/lib/Drupal.php(197): Symfony\Component\DependencyInjection\ContainerBuilder->get('file_system')
#3 /persist/drupal/web/core/modules/sqlite/src/Driver/Database/sqlite/Install/Tasks.php(79): Drupal::service('file_system')
#4 /persist/drupal/web/core/lib/Drupal/Core/Database/Install/Tasks.php(150): Drupal\sqlite\Driver\Database\sqlite\Install\Tasks->connect()
#5 /persist/drupal/web/core/includes/install.core.inc(1228): Drupal\Core\Database\Install\Tasks->runTasks()
#6 /persist/drupal/web/core/includes/install.core.inc(1177): install_database_errors(Array, './sites/default...')
#7 /persist/drupal/web/core/includes/install.core.inc(391): install_verify_database_settings('sites/default')
#8 /persist/drupal/web/core/includes/install.core.inc(119): install_begin_request(Object(Composer\Autoload\ClassLoader), Array)
#9 /persist/drupal/web/core/install.php(48): install_drupal(Object(Composer\Autoload\ClassLoader))
#10 {main}
thrown in <b>/persist/drupal/vendor/symfony/dependency-injection/ContainerBuilder.php</b> on line <b>992</b><br />
The minimal container created in install_begin_request doesn't setup the service before invoking install_verify_database_settings
Steps to reproduce
Try to install Drupal with an existing sites/default/settings.php that contains
$databases['default']['default'] = array (
'database' => 'sites/default/files/.sqlite',
'prefix' => '',
'driver' => 'sqlite',
'namespace' => 'Drupal\\sqlite\\Driver\\Database\\sqlite',
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
);
Proposed resolution
Register file_system
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3463572
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mglamanComment #3
mglamanThe comment here in
\Drupal\sqlite\Driver\Database\sqlite\Install\Tasks::connectmakes no sense:\Drupal\Core\File\FileSystem::getTempDirectorydoes not use the database. It reads from settings and other static methods.However,
\Drupal\Core\File\FileSystem::tempnamuses stream wrappers which requires a full container.EDIT: Maybe it's due to this line
Comment #4
mglamanOkay, given this code:
The result of
sys_get_temp_dir()will not use a stream wrapper.\Drupal\Core\File\FileSystem::tempnamis mostly for handling a tempnam the starts with a stream wrapper scheme. We'll never have that. We should just usetempnamdirectly.Comment #6
mglamanComment #7
mglamanThis won't work because the connection class uses file_system in createDatabase: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/sqlit...
Comment #8
andypostI think that's related to #3225473: Use \Drupal\Core\File\FileSystemInterface::getTempDirectory() instead of sys_get_temp_dir() where possible
Comment #9
mglamanIt's related, and adds more reliable on the file_system (which I think is not avoidable.)
Comment #10
andypostThat fix also has own issue) #2724963: Make the public file system an optional configuration
Comment #11
mglamanComment #12
moshe weitzman commentedI've come across this too when testing the Drush site:install command on sqlite.
Comment #13
pameeela commentedNo longer a Starshot blocker now that WASM is out.
Comment #14
mxr576For other curious ppl like /me who would like to what this means and why: #3486415: Remove the WebAssembly trial