pimcore/demo

[Bug]: Error with composer create-project

Closed this issue · 17 comments

Expected behavior

No error

Actual behavior

Error:
An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory

Steps to reproduce

Execute as described in the README:
COMPOSER_MEMORY_LIMIT=-1 composer create-project pimcore/demo my-project

After debugging, it seems that the GenericExecutionEngineBundle needs a DB connection. However, the connection will be configured in the step ./vendor/bin/pimcore-install.

In this step an error occurs because the MkdirCacheWarmer was not executed. The temp directory is not created, and the requirement check is failing:
php: ../../magick/exception.c:1121: ThrowMagickExceptionList: Assertion `exception != (ExceptionInfo *) NULL' failed.

So the error should be since this PR #583

@mcop1 Can you look into this?

Hmm ... as far as we understand this, do we have following situation:
Doctrine ORM needs a DB connection during cache:clear when server_version is not known to it - at least sometimes.
Right now, composer create project runs the scripts defined in composer.json, which contains cache:clear the command.

For the tests we solved it like here: https://github.com/pimcore/demo/pull/583/files#diff-d7b672fd527bb6f82ceb3c23b6f417911c595d020f4a14aac07cad73936dbf0cR66-R101

Any better solutions are highly appreciated.

@fashxp Can we set a server_version? So that composer create-project is possible again. I think the installer should then set the correct server_version anyway.

If this is working, I have no idea to be honest...

kmpm commented

Is there any available workaround to this?
It is somewhat frustrating to not even getting past the installation step of the "Getting started" guide.

Just continue with pimcore installation, should work

The workaround is to run the command with "--no-install" and then run "composer install"

kmpm commented

--no-install + compose install does not work.
The compose install step generates the same error.
Just continuing after create-project works or running create-project with --no-script seem to work.

Wasn't able to find the exact source of the problem other than the fact that the GenericExecutionEngine uses Entities, while it is not used in other "older" bundles.

I've opened a PR #603 that potentially works around this error by doing --no-script as suggested and confirmed by @kmpm

@fashxp Can we set a server_version? So that composer create-project is possible again. I think the installer should then set the correct server_version anyway.

That was a viable alternative, probably for the demo, we could put a placeholder value since we kind of have "control" over which image will be used and which server_version would likely be

@blankse when setting server_version in config, there's no auto-detection anymore, afaik.

Basically it's caused by bundles using the doctrine db service, instead of Pimcore\Db::get() that we used as a workaround in the past (see https://github.com/search?q=org%3Apimcore+Db%3A%3Aget%28%29&type=code&p=2) .
But to be honest, I'd prefer to separate out cache:clear or maybe even remove all scripts from composer.json and ask the user to run the commands manually. I'd assume this also makes debugging easier in case something goes wrong, when the commands are not wrapped / triggered by another one.

@brusch @kingjia90 But you cannot run pimcore-install without first running cache:clear (because you need the temp directory from the MkdirCacheWarmer). Otherwise, I get this error: php: ../../magick/exception.c:1121: ThrowMagickExceptionList: Assertion 'exception != (ExceptionInfo *) NULL' failed. However, cache:clear requires the database, but the database is configured by pimcore-install. It's a classic chicken-and-egg problem.

@blankse Thank you for the feedback, but weird, i don't encounter that mentioned issue with magick

docker run -u `id -u`:`id -g` --rm -v `pwd`:/var/www/html pimcore/pimcore:php8.3-latest composer create-project --no-scripts pimcore/demo:dev-workaround-create-project my-temp-project

and

cd my-temp-project/; docker compose up -d;
docker compose exec php bin/console assets:install --symlink --relative;docker compose exec php vendor/bin/pimcore-install --mysql-host-socket=db --mysql-username=pimcore --mysql-password=pimcore --mysql-database=pimcore

Image

@kingjia90 Ok, than it is a Imagick specific error. I use ddev and there the docker image. There this imagick version is used:
Image

This error is also reported in Gitter:
https://matrix.to/#/!gdGFKKpLPNuNeXpFJY:gitter.im/$tAb2heXgAIaIS88qZacuZ9hncla7pY_yDcJMFdIU5qE?via=gitter.im&via=matrix.org&via=matrix.freyachat.eu

Ah i see, tried ddev (btw didn't about it, and now i love it 😄 ) and could reproduce the same situation, after ddev . mkdir ./var/tmp, the pimcore-install would work, then i'd say that the installer should be creating these folder from the warmup, if they are somehow required for the Tools/Requirement check or skip it for imagick on install (as it's optional and not mandatory)? 🤔

@kingjia90 agree, the installer should tackle this as well and should create all necessary directories👍

With pimcore/pimcore#17767 seems working fine

Tested by running

mkdir ddevtest;
cd ddevtest/;
ddev config --auto;
ddev composer create --no-scripts  pimcore/demo:dev-createproject;
ddev . vendor/bin/pimcore-install --mysql-host-socket=db --mysql-username=db --mysql-password=db --mysql-database=db;

Closing as resolved by #603
The other issue related to imagick will be resolved in the Core

Thank you all again