Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean build fatal error : Uncaught PDOException #6

Closed
stardothosting opened this issue Oct 7, 2024 · 5 comments
Closed

Clean build fatal error : Uncaught PDOException #6

stardothosting opened this issue Oct 7, 2024 · 5 comments

Comments

@stardothosting
Copy link

stardothosting commented Oct 7, 2024

Doesnt appear that the environment variables are being set or are being parsed correctly

/opt/assetgrabber $ ./assetgrabber 

Warning: Undefined array key "DB_HOST" in /opt/assetgrabber/config/autoload/defaults.global.php on line 23

Warning: Undefined array key "DB_NAME" in /opt/assetgrabber/config/autoload/defaults.global.php on line 24

Warning: Undefined array key "DB_USER" in /opt/assetgrabber/config/autoload/defaults.global.php on line 25

Warning: Undefined array key "DB_PASS" in /opt/assetgrabber/config/autoload/defaults.global.php on line 26

Warning: Undefined array key "DB_SCHEMA" in /opt/assetgrabber/config/autoload/defaults.global.php on line 27

Fatal error: Uncaught PDOException: SQLSTATE[08006] [7] could not translate host name "dbname=" to address: Name does not resolve in /opt/assetgrabber/vendor/aura/sql/src/ExtendedPdo.php:103
Stack trace:
#0 /opt/assetgrabber/vendor/aura/sql/src/ExtendedPdo.php(103): PDO->__construct('pgsql:host=;dbn...', NULL, Object(SensitiveParameterValue), Array)
#1 /opt/assetgrabber/vendor/aura/sql/src/AbstractExtendedPdo.php(210): Aura\Sql\ExtendedPdo->connect()
#2 /opt/assetgrabber/src/Factories/ExtendedPdoFactory.php(20): Aura\Sql\AbstractExtendedPdo->exec('SET search_path...')
#3 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(629): AssetGrabber\Factories\ExtendedPdoFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'Aura\\Sql\\Extend...', NULL)
#4 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(215): Laminas\ServiceManager\ServiceManager->doCreate('Aura\\Sql\\Extend...')
#5 /opt/assetgrabber/src/Factories/Plugins/PluginMetadataServiceFactory.php(15): Laminas\ServiceManager\ServiceManager->get('Aura\\Sql\\Extend...')
#6 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(629): AssetGrabber\Factories\Plugins\PluginMetadataServiceFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'AssetGrabber\\Se...', NULL)
#7 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(215): Laminas\ServiceManager\ServiceManager->doCreate('AssetGrabber\\Se...')
#8 /opt/assetgrabber/src/Factories/Plugins/PluginDownloadFromWpServiceFactory.php(16): Laminas\ServiceManager\ServiceManager->get('AssetGrabber\\Se...')
#9 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(629): AssetGrabber\Factories\Plugins\PluginDownloadFromWpServiceFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'AssetGrabber\\Se...', NULL)
#10 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(215): Laminas\ServiceManager\ServiceManager->doCreate('AssetGrabber\\Se...')
#11 /opt/assetgrabber/src/Factories/Plugins/InternalPluginDownloadCommandFactory.php(15): Laminas\ServiceManager\ServiceManager->get('AssetGrabber\\Se...')
#12 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(629): AssetGrabber\Factories\Plugins\InternalPluginDownloadCommandFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'AssetGrabber\\Co...', NULL)
#13 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(215): Laminas\ServiceManager\ServiceManager->doCreate('AssetGrabber\\Co...')
#14 /opt/assetgrabber/assetgrabber(31): Laminas\ServiceManager\ServiceManager->get('AssetGrabber\\Co...')
#15 {main}

Next Laminas\ServiceManager\Exception\ServiceNotCreatedException: Service with name "Aura\Sql\ExtendedPdoInterface" could not be created. Reason: SQLSTATE[08006] [7] could not translate host name "dbname=" to address: Name does not resolve in /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php:636
Stack trace:
#0 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(215): Laminas\ServiceManager\ServiceManager->doCreate('Aura\\Sql\\Extend...')
#1 /opt/assetgrabber/src/Factories/Plugins/PluginMetadataServiceFactory.php(15): Laminas\ServiceManager\ServiceManager->get('Aura\\Sql\\Extend...')
#2 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(629): AssetGrabber\Factories\Plugins\PluginMetadataServiceFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'AssetGrabber\\Se...', NULL)
#3 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(215): Laminas\ServiceManager\ServiceManager->doCreate('AssetGrabber\\Se...')
#4 /opt/assetgrabber/src/Factories/Plugins/PluginDownloadFromWpServiceFactory.php(16): Laminas\ServiceManager\ServiceManager->get('AssetGrabber\\Se...')
#5 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(629): AssetGrabber\Factories\Plugins\PluginDownloadFromWpServiceFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'AssetGrabber\\Se...', NULL)
#6 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(215): Laminas\ServiceManager\ServiceManager->doCreate('AssetGrabber\\Se...')
#7 /opt/assetgrabber/src/Factories/Plugins/InternalPluginDownloadCommandFactory.php(15): Laminas\ServiceManager\ServiceManager->get('AssetGrabber\\Se...')
#8 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(629): AssetGrabber\Factories\Plugins\InternalPluginDownloadCommandFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'AssetGrabber\\Co...', NULL)
#9 /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(215): Laminas\ServiceManager\ServiceManager->doCreate('AssetGrabber\\Co...')
#10 /opt/assetgrabber/assetgrabber(31): Laminas\ServiceManager\ServiceManager->get('AssetGrabber\\Co...')
#11 {main}
  thrown in /opt/assetgrabber/vendor/laminas/laminas-servicemanager/src/ServiceManager.php on line 636
@stardothosting stardothosting changed the title Clean build fatal error : Uncaught PDOException: SQLSTATE[08006] [7] could not translate host name "dbname=" to address: Name does not resolve in /opt/assetgrabber/vendor/aura/sql/src/ExtendedPdo.php:103 Clean build fatal error : Uncaught PDOException Oct 7, 2024
@sarah-savage
Copy link
Member

You'll need to copy the .env.dist file to .env and populate it with credentials to connect to Postgres. I recommend cloning AspireCloud and using the make migrate command there to create the database.

@stardothosting
Copy link
Author

Yes the .env was copied and an empty database + credentials created -- not sure why what was entered in the .env was not being translated to building -> running the docker container.

This error was resolved by creating a development.config.php file in code/config with the database connection info there, but obviously the .env file would have been more ideal. I'll try a few more clean repo clones and tests to confirm.

@sarah-savage
Copy link
Member

Let me create a clean build myself and see if I can reproduce.

@sarah-savage
Copy link
Member

Okay, so here's what I think you can do here...

I turned the build and buil-dev commands into build-prod, build-dev, build-prod-aws and build-dev-aws. For local dev, you can just run build-dev and it should not error.

make init will run build-dev and also install Composer, and run the migrations.

Make sure you provide an external network that is shared between the database and your dev instance. For example, I use wp-services as my network.

You can define an external network by running docker network create wp-services and then make that network for the database server and the dev enviornment.

Let me know if that helps. I'll update the README too.

@sarah-savage
Copy link
Member

Updated the README with instructions on how to set this up. Also, we now have a Docker Compose configuration in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants