Problem/Motivation
If you attempt to install Drupal against a database with existing content, you'll receive this obtuse error, which does not explain how to recover:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "<front>" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 147 of /private/var/www/git/drupal8/docroot/drupal/core/lib/Drupal/Core/Routing/RouteProvider.php).
To replicate:
Install drupal 8 to new database.
Remove pointer to database by copying default.settings.php to settings.php
Drupal attempts to re-install.
Using original database connection in install.php creates exception
Additional uncaught exception thrown while handling exception.
Original
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "<front>" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 147 of /private/var/www/git/drupal8/docroot/drupal/core/lib/Drupal/Core/Routing/RouteProvider.php).
Drupal\Core\Routing\RouteProvider->getRouteByName('')
Drupal\Core\Routing\UrlGenerator->getRoute('')
Drupal\Core\Routing\UrlGenerator->generateFromRoute('', Array, Array)
Drupal::url('')
template_preprocess_page(Array)
template_preprocess_maintenance_page(Array)
template_preprocess_install_page(Array, 'install_page', Array)
_theme('install_page', Array)
Drupal\Core\Theme\ThemeManager->render('install_page', Array)
drupal_render(Array)
Drupal\Core\Page\DefaultHtmlPageRenderer::renderPage(Array, 'Installing Drupal', 'install', Array)
install_display_output(Array, Array)
install_drupal()
Additional
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "<front>" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 147 of /private/var/www/git/drupal8/docroot/drupal/core/lib/Drupal/Core/Routing/RouteProvider.php).
Drupal\Core\Routing\RouteProvider->getRouteByName('')
Drupal\Core\Routing\UrlGenerator->getRoute('')
Drupal\Core\Routing\UrlGenerator->generateFromRoute('', Array, Array)
Drupal::url('')
template_preprocess_page(Array)
template_preprocess_maintenance_page(Array)
template_preprocess_install_page(Array, 'install_page', Array)
_theme('install_page', Array)
Drupal\Core\Theme\ThemeManager->render('install_page', Array)
drupal_render(Array)
Drupal\Core\Page\DefaultHtmlPageRenderer::renderPage(Array, 'Error', 'install', Array)
install_display_output(Array, Array)
_drupal_log_error(Array, 1)
_drupal_exception_handler(Object)
Proposed resolution
Print out a simple message like Drupal 7 used to do.
Remaining tasks
User interface changes
API changes
Comments
Comment #1
richardcanoe commentedComment #2
larsmw commentedI can confirm this on a Debian 7 setup.
php : 5.4.4-14+deb7u9
Mysql-server : 5.5.37
This is apearing when installing to a non-empty database.
Comment #3
richardcanoe commentedComment #4
richardcanoe commentedComment #5
larsmw commentedThis happens when you try to install onto a nonempty database. So instead of telling that there is content in the database the installer throws this exception.
The expected behavior might be to get a warning that the database is not empty and ready for install. Is it supposed that you should be able to install over a non-empty database? Or should there be a meaningful error message to guide the user to select another database?
Comment #6
yanniboi commentedI agree with @larsmw.
The installer should not attempt to install on a used database, but should display an error message asking users to create a new (clean) database.
Comment #7
gmasky commentedI am getting this error while trying to install on a new DB https://www.drupal.org/node/2348817
Comment #8
richardcanoe commentedAlreadyInstalledException exists, but is not being called
Comment #9
larsmw commentedI think this should be handled in 'install.core.inc' file in the
install_begin_request(&$install_state)function around line 340 where there is a check for which tables exists in the database!?Does this assumption sound right?
Comment #10
larsmw commentedI breefly discussed this with @Crell, and he suggested to make an Install Task to check the state of the database and on base of that give an apropriate message to the user.
Comment #11
larowlanThe issue is the URL generation in the maintenance page is wrong when the site is in such a low level install state.
Comment #12
miraj9093 commentedI am getting the same errror in installation in clean new Database. I am using drupal 8-0 beta , Apache-php-mysql with windows.
Comment #13
webchickThis should be at least major IMO, if not critical.
Comment #14
webchickUpdating the issue summary a bit.
Comment #15
webchickComment #16
webchickAnd yeah, given that D7 used to handle this condition fine, critical. One last update; sorry for the noise.
Comment #17
myforgedoteu commentedCurrently adding an install task to check if the database is already installed and throw the exception in AlreadyInstalledException
Preventing the script to try to run over the already installed database and throw this routing error
Comment #18
webchickIt'd be sweet if this could somehow be done without adding a new step to the installer. We've taken care to try and *remove* steps from the installer in this release elsewhere. If it can't though, so be it.
Comment #19
myforgedoteu commentedit might be done without a new step in fact, will have first to fix the routing error, then it should process the regular path of the installer and reach the error thrown by AlreadyInstalledException
Comment #20
dawehnerThere are several problems involved here:
\Drupal::url('<front>');does not follow this ruleComment #21
myforgedoteu commentedas @dawehner started, the call to the front page might be fixed and now while testing the installer throw no routing errors while trying to install it on the same database.
But still need to modify the installer to prevent the installation on the same database. We are still able to install on the same one after patching the url routing.
Comment #22
myforgedoteu commentedComment #24
cilefen commentedReroll of #21. The situation in #23 is the same.
Comment #26
yannickooI could apply your patch but got the following error:
Additional uncaught exception thrown while handling exception.Original
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "<current>" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 149 of /vagrant/code/d8/core/lib/Drupal/Core/Routing/RouteProvider.php).
Drupal\Core\Routing\RouteProvider->getRouteByName('') Drupal\Core\Routing\UrlGenerator->getRoute('') Drupal\Core\Routing\UrlGenerator->getPathFromRoute('', Array) Drupal\Core\Url->getInternalPath() system_theme_suggestions_html(Array) call_user_func_array('system_theme_suggestions_html', Array) Drupal\Core\Extension\ModuleHandler->invokeAll('theme_suggestions_html', Array) Drupal\Core\Theme\ThemeManager->theme('html', Array) Drupal\Core\Theme\ThemeManager->render('html', Array) Drupal\Core\Render\Renderer->render(Array) Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Installing Drupal', 'install_page', Array) install_display_output(Array, Array) install_drupal()Additional
LogicException: A stray drupal_render() invocation with $is_root_call = TRUE is causing bubbling of attached assets to break. in Drupal\Core\Render\Renderer->render() (line 335 of /vagrant/code/d8/core/lib/Drupal/Core/Render/Renderer.php).
Comment #27
xjm#2352081: Prevent installation over an already installed database is fixed, so we can close this issue now.