-2

I am trying to run a test site on a server. It's written in Symfony 5.1. I get an error:

The parameter "env(DATABASE_URL)" has a dependency on a non-existent parameter "F)".

My DATABASE_URL in .env file is in a format of: DATABASE_URL="mysql://user:password@localhost:3306/databaseName?serverVersion=mariadb-10.4.21"

I have tested many versions of DATABASE_URL string.

The details about the error:

Symfony\Component\DependencyInjection\Exception
ParameterNotFoundException

in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php (line 98) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php -> get (line 61) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php -> get (line 227) ParameterBag->Symfony\Component\DependencyInjection\ParameterBag{closure}(array('%F)%', 'F)')) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php preg_replace_callback (line 216) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php -> resolveString (line 185) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/ParameterBag/ParameterBag.php -> resolveValue (line 145) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/ParameterBag/EnvPlaceholderParameterBag.php -> resolve (line 146) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/Compiler/ResolveParameterPlaceHoldersPass.php -> resolve (line 59) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/Compiler/Compiler.php -> process (line 91) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/dependency-injection/ContainerBuilder.php -> compile (line 736) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/http-kernel/Kernel.php -> compile (line 533) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/http-kernel/Kernel.php -> initializeContainer (line 131) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/symfony/vendor/symfony/http-kernel/Kernel.php -> boot (line 191) Kernel->handle(object(Request)) in /home/gokblaxdds/domains/gokblaxdds.cfolks.pl/public_html/index.php (line 30)

I didn't find any 'F)' in my code.

My doctrine.yaml:

    dbal:
        url: '%env(resolve:DATABASE_URL)%'

        # IMPORTANT: You MUST configure your server version,
        # either here or in the DATABASE_URL env var (see .env file)
        #server_version: '5.7'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App```
brnina
  • 27
  • 1
  • 4
  • 1
    Can you share any details about that environment string? Does it contain any special characters? – Nico Haase Nov 01 '21 at 14:08
  • Maybe check your configs, too – Chris Haas Nov 01 '21 at 15:09
  • @NicoHaase The password has underscores and dashes, username and database name have underscores. – brnina Nov 01 '21 at 16:22
  • @ChrisHaas Which config do you mean? I added doctrine.yaml to the question. Is parameters.yaml still used? I don't have such file. – brnina Nov 01 '21 at 16:24
  • Maybe try to remove `resolve:`? – Chris Haas Nov 01 '21 at 16:34
  • @ChrisHaas Unfortunately, it didn't help. Do you have some other ideas? – brnina Nov 01 '21 at 17:55
  • 1
    Did you clear the cache after changing it? No matter what, I don't think there should be a need to `resolve` that parameter, it is literal and the `env` function should take care of parsing it. I'm seen some people mention trying to URL encode the value that's in `DATABASE_URL` in your `.env`, you could try that, too. – Chris Haas Nov 01 '21 at 18:19
  • @ChrisHaas When I clear cache, I get the same message, so I removed cache manually but it didn't help. Encoding didn't help too. – brnina Nov 01 '21 at 18:54
  • @ChrisHaas I think I remove cache in the wrong way. Now I have seen that in the stack trace there is an old password or something similar. – brnina Nov 01 '21 at 19:03
  • I was looking at the wrong file. I had "%" in the password in parameters.yaml. – brnina Nov 06 '21 at 13:07

1 Answers1

0

If you have this error or a similar one, update your DATABASE_URL (I had something like "F)%s" in the password). Don't use "%" or "?" in your password or follow Chris Haas advice to url-encode the string or remove "resolve". I couldn't get it right because I forgot that I have parameters.yaml file, which has overwritten the value of DATABASE_URL in env files.

Probably related: Symfony 4 Dotenv escape special characters https://github.com/symfony/symfony/issues/26721

brnina
  • 27
  • 1
  • 4
  • How is this related to the `parameters.yaml` file? According to the comment section: "The password has underscores and dashes, username and database name have underscores" – Nico Haase Nov 05 '21 at 12:17
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 05 '21 at 15:09
  • @NicoHaase I was looking at the wrong file. What else can I add to this answer? I don't have the copy of this unfortunate password. – brnina Nov 06 '21 at 10:36