Closed ADmad closed 3 years ago
Also after project creating I modified .env
and set DATABASE_URL
to appropriate value to use mysql with required credentials. Yet trying to run bin/console bolt:setup
or accesing the site in browser still gives the error An exception occurred in driver: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'
.
I think there's a few steps missing in your description.
The installer shouldn't be trying to clear cache / connect to database before proper db credentials are setup.
It doesn't, or at least it shouldn't. Could you give more details about what steps you did?
composer create-project bolt/project bolt4
is the only command I ran and the output is the one provided above (I just redacted the output composer showed when installing packages, as it's not relevant).
Any way, here's the full output:
$ composer create-project bolt/project bolt4
Creating a "bolt/project" project at "./bolt4"
Installing bolt/project (1.2.1)
- Installing bolt/project (1.2.1): Loading from cache
Created project in /srv/sites/bolt4
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 164 installs, 0 updates, 0 removals
- Installing symfony/flex (v1.9.4): Loading from cache
- Installing composer/package-versions-deprecated (1.11.99): Loading from cache
- Installing symfony/polyfill-ctype (v1.18.1): Loading from cache
- Installing composer/ca-bundle (1.2.8): Loading from cache
- Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache
- Installing twig/twig (v3.0.5): Loading from cache
- Installing symfony/polyfill-php80 (v1.18.1): Loading from cache
- Installing psr/container (1.0.0): Loading from cache
- Installing symfony/service-contracts (v2.2.0): Loading from cache
- Installing symfony/polyfill-php73 (v1.18.1): Loading from cache
- Installing psr/log (1.1.3): Loading from cache
- Installing symfony/filesystem (v5.1.5): Loading from cache
- Installing symfony/process (v5.1.5): Loading from cache
- Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache
- Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache
- Installing symfony/string (v5.1.5): Loading from cache
- Installing symfony/console (v5.1.5): Loading from cache
- Installing symfony/finder (v5.1.5): Loading from cache
- Installing seld/phar-utils (1.1.1): Loading from cache
- Installing seld/jsonlint (1.8.2): Loading from cache
- Installing justinrainbow/json-schema (5.2.10): Loading from cache
- Installing composer/xdebug-handler (1.4.3): Loading from cache
- Installing composer/spdx-licenses (1.5.4): Loading from cache
- Installing composer/semver (1.7.0): Loading from cache
- Installing composer/composer (1.10.13): Loading from cache
- Installing drupol/composer-packages (1.1.2): Loading from cache
- Installing bobdenotter/configuration-notices (1.1.5): Loading from cache
- Installing bobdenotter/weatherwidget (1.1.2): Loading from cache
- Installing bolt/article (1.0.9): Loading from cache
- Installing bolt/assets (4.0.0): Loading from cache
- Installing ezyang/htmlpurifier (v4.13.0): Loading from cache
- Installing xemlock/htmlpurifier-html5 (v0.1.11): Loading from cache
- Installing webonyx/graphql-php (v0.13.9): Loading from cache
- Installing webmozart/assert (1.9.1): Loading from cache
- Installing webmozart/path-util (2.3.0): Loading from cache
- Installing webimpress/safe-writer (2.1.0): Loading from cache
- Installing ua-parser/uap-php (v3.9.13): Loading from cache
- Installing symfony/var-dumper (v5.1.5): Loading from cache
- Installing tightenco/collect (v7.26.1): Loading from cache
- Installing symfony/deprecation-contracts (v2.2.0): Loading from cache
- Installing symfony/yaml (v5.1.5): Loading from cache
- Installing symfony/http-foundation (v5.1.5): Loading from cache
- Installing psr/event-dispatcher (1.0.0): Loading from cache
- Installing symfony/event-dispatcher-contracts (v2.2.0): Loading from cache
- Installing symfony/event-dispatcher (v5.1.5): Loading from cache
- Installing symfony/error-handler (v5.1.5): Loading from cache
- Installing symfony/http-kernel (v5.1.5): Loading from cache
- Installing symfony/dependency-injection (v5.1.5): Loading from cache
- Installing symfony/config (v5.1.5): Loading from cache
- Installing symfony/asset (v5.1.5): Loading from cache
- Installing symfony/webpack-encore-bundle (v1.7.3): Loading from cache
- Installing symfony/web-server-bundle (v4.4.13): Loading from cache
- Installing symfony/translation-contracts (v2.2.0): Loading from cache
- Installing symfony/twig-bridge (v5.1.5): Loading from cache
- Installing symfony/twig-bundle (v5.1.5): Loading from cache
- Installing symfony/routing (v5.1.5): Loading from cache
- Installing symfony/var-exporter (v5.1.5): Loading from cache
- Installing psr/cache (1.0.1): Loading from cache
- Installing symfony/cache-contracts (v2.2.0): Loading from cache
- Installing symfony/cache (v5.1.5): Loading from cache
- Installing symfony/framework-bundle (v5.1.5): Loading from cache
- Installing symfony/web-profiler-bundle (v5.1.5): Loading from cache
- Installing symfony/validator (v5.1.5): Loading from cache
- Installing symfony/translation (v5.1.5): Loading from cache
- Installing symfony/stopwatch (v5.1.5): Loading from cache
- Installing symfony/serializer (v5.1.5): Loading from cache
- Installing symfony/security-core (v5.1.5): Loading from cache
- Installing symfony/property-info (v5.1.5): Loading from cache
- Installing symfony/property-access (v5.1.5): Loading from cache
- Installing symfony/security-http (v5.1.5): Loading from cache
- Installing symfony/security-guard (v5.1.5): Loading from cache
- Installing symfony/security-csrf (v5.1.5): Loading from cache
- Installing symfony/security-bundle (v5.1.5): Loading from cache
- Installing symfony/polyfill-php72 (v1.18.1): Loading from cache
- Installing monolog/monolog (2.1.1): Loading from cache
- Installing symfony/monolog-bridge (v5.1.5): Loading from cache
- Installing symfony/monolog-bundle (v3.5.0): Loading from cache
- Installing nikic/php-parser (v4.10.1): Loading from cache
- Installing doctrine/inflector (1.4.3): Loading from cache
- Installing symfony/maker-bundle (v1.21.1): Loading from cache
- Installing paragonie/random_compat (v9.99.99): Loading from cache
- Installing symfony/polyfill-php70 (v1.18.1): Loading from cache
- Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache
- Installing symfony/mime (v5.1.5): Loading from cache
- Installing doctrine/lexer (1.2.1): Loading from cache
- Installing egulias/email-validator (2.1.21): Loading from cache
- Installing symfony/mailer (v5.1.5): Loading from cache
- Installing symfony/http-client-contracts (v2.2.0): Loading from cache
- Installing symfony/http-client (v5.1.5): Loading from cache
- Installing symfony/options-resolver (v5.1.5): Loading from cache
- Installing symfony/intl (v5.1.5): Loading from cache
- Installing symfony/polyfill-intl-icu (v1.18.1): Loading from cache
- Installing symfony/form (v5.1.5): Loading from cache
- Installing symfony/expression-language (v5.1.5): Loading from cache
- Installing symfony/dotenv (v5.1.5): Loading from cache
- Installing symfony/debug-bundle (v5.1.5): Loading from cache
- Installing squirrelphp/twig-php-syntax (v1.5.1): Loading from cache
- Installing siriusphp/validation (3.0.1): Loading from cache
- Installing siriusphp/upload (3.0.1): Loading from cache
- Installing sensiolabs/security-checker (v6.0.3): Loading from cache
- Installing doctrine/annotations (1.10.4): Loading from cache
- Installing sensio/framework-extra-bundle (v5.6.1): Loading from cache
- Installing scienta/doctrine-json-functions (4.1.2): Loading from cache
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing phpdocumentor/reflection-common (2.2.0): Loading from cache
- Installing phpdocumentor/type-resolver (1.4.0): Loading from cache
- Installing phpdocumentor/reflection-docblock (4.3.4): Loading from cache
- Installing php-translation/common (3.0.1): Loading from cache
- Installing php-translation/symfony-storage (2.2.0): Loading from cache
- Installing php-translation/extractor (2.0.2): Loading from cache
- Installing nyholm/nsa (1.2.1): Loading from cache
- Installing php-translation/symfony-bundle (0.12.1): Loading from cache
- Installing peterkahl/country-code-to-emoji-flag (v1.2): Loading from cache
- Installing nesbot/carbon (2.40.1): Loading from cache
- Installing nelmio/cors-bundle (2.1.0): Loading from cache
- Installing miljar/php-exif (v0.6.5): Loading from cache
- Installing psr/http-message (1.0.1): Loading from cache
- Installing league/mime-type-detection (1.5.0): Loading from cache
- Installing league/flysystem (1.1.3): Loading from cache
- Installing ralouphie/getallheaders (3.0.3): Loading from cache
- Installing guzzlehttp/psr7 (1.6.1): Loading from cache
- Installing intervention/image (2.5.1): Loading from cache
- Installing league/glide (1.6.0): Loading from cache
- Installing league/glide-symfony (1.0.4): Loading from cache
- Installing knplabs/knp-menu (v3.1.2): Loading from cache
- Installing knplabs/knp-menu-bundle (v3.0.0): Loading from cache
- Installing nette/utils (v3.1.3): Loading from cache
- Installing nette/finder (v2.5.2): Loading from cache
- Installing symplify/package-builder (8.3.17): Loading from cache
- Installing ramsey/collection (1.1.1): Loading from cache
- Installing brick/math (0.9.1): Loading from cache
- Installing ramsey/uuid (4.1.1): Loading from cache
- Installing doctrine/reflection (1.2.1): Loading from cache
- Installing doctrine/event-manager (1.1.1): Loading from cache
- Installing doctrine/collections (1.6.7): Loading from cache
- Installing doctrine/cache (1.10.2): Loading from cache
- Installing doctrine/persistence (2.0.0): Loading from cache
- Installing doctrine/instantiator (1.3.1): Loading from cache
- Installing doctrine/dbal (2.10.4): Loading from cache
- Installing doctrine/common (3.0.2): Loading from cache
- Installing doctrine/orm (v2.7.3): Loading from cache
- Installing knplabs/doctrine-behaviors (v2.0.7): Loading from cache
- Installing fzaninotto/faker (v1.9.1): Loading from cache
- Installing erusev/parsedown (1.7.4): Loading from cache
- Installing embed/embed (v3.4.8): Loading from cache
- Installing symfony/doctrine-bridge (v5.1.5): Loading from cache
- Installing doctrine/sql-formatter (1.1.1): Loading from cache
- Installing doctrine/doctrine-bundle (2.1.2): Loading from cache
- Installing doctrine/data-fixtures (1.4.4): Loading from cache
- Installing doctrine/doctrine-fixtures-bundle (3.3.2): Loading from cache
- Installing cocur/slugify (v4.0.0): Loading from cache
- Installing bolt/common (2.1.7): Loading from cache
- Installing beberlei/doctrineextensions (v1.2.7): Loading from cache
- Installing pagerfanta/pagerfanta (v2.4.1): Loading from cache
- Installing babdev/pagerfanta-bundle (v2.5.2): Loading from cache
- Installing willdurand/negotiation (v2.3.1): Loading from cache
- Installing psr/link (1.0.0): Loading from cache
- Installing symfony/web-link (v5.1.5): Loading from cache
- Installing fig/link-util (1.1.1): Loading from cache
- Installing api-platform/core (v2.5.7): Loading from cache
- Installing bolt/core (4.0.0): Loading from cache
- Installing bolt/newswidget (1.2.2): Loading from cache
- Installing bolt/redactor (1.0.12): Loading from cache
- Installing bolt/themes (3.3.2): Loading from cache
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
drupol/composer-packages: Regenerating classes...
drupol/composer-packages: Done.
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear --no-warmup [KO]
[KO]
Script cache:clear --no-warmup returned with error code 1
!!
!! In AbstractMySQLDriver.php line 110:
!!
!! An exception occurred in driver: SQLSTATE[HY000] [1698] Access denied for u
!! ser 'root'@'localhost'
!!
!!
!! In PDOConnection.php line 31:
!!
!! SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'
!!
!!
!! In PDOConnection.php line 27:
!!
!! SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'
!!
!!
!! cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
!!
!!
Script @auto-scripts was called via post-install-cmd
BTW I have an actual environment variable APP_ENV
set to dev
. Could that be causing a problem (although that's the same as what the .env
file seems to set) ?
That's really peculiar.. If I run the same, I get this:
$ composer create-project bolt/project myprojectname
Creating a "bolt/project" project at "./myprojectname"
Installing bolt/project (1.2.1)
- Installing bolt/project (1.2.1): Loading from cache
Created project in /Users/bob/Sites/Bolt/myprojectname
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 164 installs, 0 updates, 0 removals
- Installing symfony/flex (v1.9.4): Loading from cache
(snip)
- Installing bolt/themes (3.3.2): Loading from cache
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
drupol/composer-packages: Regenerating classes...
drupol/composer-packages: Done.
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear --no-warmup [OK]
Executing script assets:install --symlink --relative public [OK]
Executing script bolt:copy-assets [OK]
> php bin/console extensions:configure --with-config
> php bin/console bolt:info
Bolt version: 4.0.0
* Install type: Composer install
* Database: sqlite 3.30.1 - Tables not initialised (without JSON)
* PHP version: 7.2.26
* Symfony version: v5.1.5
* Operating System: Darwin - 19.6.0
> php bin/post-create-project.php
> php bin/console bolt:copy-themes
Installing Bolt themes as hard copies.
--- ----------- ----------------
Theme Method / Error
--- ----------- ----------------
β base-2021 copied
β base-2018 copied
β skeleton copied
--- ----------- ----------------
[OK] All themes were successfully installed.
$
The installation copies https://github.com/bolt/project/blob/master/.env.dist to .env
, and it should use that. It uses SQLite, so i'm not sure why it uses "root" for MySQL in your case..
Unless you've set another DATABASE_URL
in your ENV for this project, this should work.
edit I just now saw your last comment.. Looks like that could be the culprit, yes.
Unless you've set another DATABASE_URL in your ENV for this project, this should work. edit I just now saw your last comment.. Looks like that could be the culprit, yes.
To confirm I don't have any DATABASE_URL
set, just APP_ENV
, which is the same value in the .env
file.
Do you have a clue why it insist on using root@localhost
, instead of the one that's configured in the file?
https://github.com/bolt/project/blob/master/.env.dist#L21
Your version of the file does say that, right?
Do you have a clue why it insist on using root@localhost, instead of the one that's configured in the file?
No clue. The .env
created under the project folder is identical to https://github.com/bolt/project/blob/master/.env.dist
. The error occurs during composer create-project
command itself so I haven't even had a chance to modify the .env
.
Even if I do modify DATABASE_URL
in .env
it still tries to connect to MySQL using root@localhost
.
That must be something in your ENV though.. Does printenv | grep DATABASE_URL
print something?
Does printenv | grep DATABASE_URL print something?
No.
Then I have no idea why it does that. Regardless, I'm pretty sure this is a problem on your environment, and not necessarily in the project.
I'm pretty sure this is a problem on your environment
Yes that's likely but what? :slightly_smiling_face:. If bolt is picking up the db info from somewhere else besides DATABASE_URL
env var then it is potentially an issue with the project.
I realize that since it's an env specific issue it's difficult for you to debug, so I will try to dig into it myself.
Yes that's likely but what?
I wish i knew! π
If bolt is picking up the db info from somewhere else besides DATABASE_URL env var then it is potentially an issue with the project.
Yes, that's true.. I think it's either "working correctly, but not as intended", or it is "working incorrectly, for some reason". Don't know which, though.
Either way: If you can figure out what's causing it, the very least we can do is document it, and add a caveat to the docs about this peculiar quirk. :-)
Figured it out. Since I have APP_ENV
already set the .env
file is not loaded and the ORM tries to use some defaults.
Perhaps loading the .env
should not be skipped if APP_ENV
is dev
.
I think the index
and console
files are using outdated versions. The default index.php in Symfony 5.1 looks like this, and has no conditional statement around the DotEnv component:
<?php
declare(strict_types=1);
use App\Kernel;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/vendor/autoload.php';
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
My installation immediately failed with the database connection error due to the .env file not being read due to the conditional - I did indeed have an APP_ENV environment variable set (to "dev").
@benr77 See also: https://github.com/bolt/project/pull/41
Closing this, because it should be fixed with the updates to .env
handling and index.php
updates to latest SF standards. Feel free to re-open if issues persist! :-)
The installer shouldn't be trying to clear cache / connect to database before proper db credentials are setup. (Trying to use root user as default isn't the best idea either).