Doctrine override_url in symfony error No such file or directory on Travis CI

I have the impression that this is a configuration problem with doctrine. Indeed my doctrine.yaml.

`doctrine:
dbal:
    dbname:               mydatabase
    host:                 localhost
    port:                 8889
    user:                 root
    password:             root
    driver:               pdo_mysql
    url:                  '%env(resolve:DATABASE_URL)%'
    unix_socket:          /Applications/MAMP/tmp/mysql/mysql.sock
    charset:              UTF8
    override_url:         true
    # IMPORTANT: You MUST configure your server version,
    # either here or in the DATABASE_URL env var (see .env file)
    #server_version: '13'
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`

When I perform tests with the database it works but on Travis CI when I do this build

`language: php
php:
   - '7.3'
   services:
    - mysql
script:
    - composer install
    - php bin/console doctrine:database:create --env=test
    - php bin/console doctrine:schema:update --force --env=test
    - php bin/console doctrine:fixtures:load -n --env=test
    - php bin/phpunit`

travis when creating the database returns me:

    `php bin/console doctrine:database:create --env=test 382[critical] Error thrown       while running command "doctrine:database:create --env=test". Message: "An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory" 383 384 385In AbstractMySQLDriver.php line 112: 386 387 An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or dir`

Thanks in advance!

According to the PR which added this depreciation, with override_url set to true , environment specific configs can override the database name (among other parameters).

So check whether config/packages/test/doctrine.yaml overrides any of the DATABASE_URLs parameters:

    $nestedConnections = ['shards', 'replicas', 'slaves'];

        foreach ($connectionDefaults as $defaultKey => $defaultValue) {

Hope this helps.

Montana Mendy

Happy building!

2 Likes

that was it! thank you @Montana