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

Composer intall Contao 4.9 under Win 10 + XAMPP "An error occurred while executing the "contao:install-web-dir" command" #582

Closed
toteph42 opened this issue Aug 22, 2020 · 9 comments

Comments

@toteph42
Copy link

I tried to install a new Contao instance in an empty directory with composer and got the following error message:

Loading composer repositories with package information Updating dependencies (including require-dev) Dependency resolution completed in 111.317 seconds Analyzed 24234 packages to resolve dependencies Analyzed 3835600 rules to resolve dependencies Nothing to install or update Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested. Generating autoload files composer/package-versions-deprecated: Generating version class... composer/package-versions-deprecated: ...done generating version class 77 packages you are using are looking for funding. Use the composer fund` command to find out more!
contao/manager-plugin: Generating plugin class...

  • Added plugin for bugbuster/contao-mobiledetection-bundle
  • Added plugin for con4gis/core
  • Added plugin for con4gis/forum
  • Added plugin for con4gis/groups
  • Added plugin for con4gis/projects
  • Added plugin for contao/core-bundle
  • Added plugin for contao/faq-bundle
  • Added plugin for contao/installation-bundle
  • Added plugin for contao/manager-bundle
  • Added plugin for isotope/isotope-core
  • Added plugin for syncgw/contao-isotope_stin
  • Added plugin for syncgw/contao-spambot
  • Added plugin for terminal42/contao-autoregistration
    contao/manager-plugin: ...done generating plugin class

post-update-cmd: Contao\ManagerBundle\Composer\ScriptHandler::initializeApplication
Script Contao\ManagerBundle\Composer\ScriptHandler::initializeApplication handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred while executing the "contao:install-web-dir" command:
Exception trace:
() at xxx\contao\vendor\contao\manager-bundle\src\Composer\ScriptHandler.php:89
Contao\ManagerBundle\Composer\ScriptHandler::executeCommand() at xxx\contao\vendor\contao\manager-bundle\src\Composer\ScriptHandler.php:30
Contao\ManagerBundle\Composer\ScriptHandler::initializeApplication() at phar://xxx/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:305
Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() at phar://xxx/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:209
Composer\EventDispatcher\EventDispatcher->doDispatch() at phar://xxx/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:96
Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar://xxx/batch/composer.phar/src/Composer/Installer.php:338
Composer\Installer->run() at phar://xxx/composer.phar/src/Composer/Command/UpdateCommand.php:163
Composer\Command\UpdateCommand->execute() at phar://xxx/composer.phar/vendor/symfony/console/Command/Command.php:245
Symfony\Component\Console\Command\Command->run() at phar://xxx/composer.phar/vendor/symfony/console/Application.php:835
Symfony\Component\Console\Application->doRunCommand() at phar://xxx/composer.phar/vendor/symfony/console/Application.php:185
Symfony\Component\Console\Application->doRun() at phar://xxx/composer.phar/src/Composer/Console/Application.php:281
Composer\Console\Application->doRun() at phar://xxx/composer.phar/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at phar://xxx/composer.phar/src/Composer/Console/Application.php:113
Composer\Console\Application->run() at phar://xxx/composer.phar/bin/composer:61
require() at xxx\composer.phar:24
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] []...
`
More @ https://contao.slack.com/archives/CK4J0KNDB/p1597910235011900

@toteph42
Copy link
Author

Ich habe es gerade mit Comtao Manager 1.27 probiert. Derselbe Fehler. Log anbei
error.log

@fritzmg
Copy link
Contributor

fritzmg commented Aug 22, 2020

Likely related to contao/manager-bundle#88

As discussed with @m-vo in Slack, we want to work on a better solution for the Composer Script Handler - for Symfony, Composer and Contao.

@m-vo
Copy link
Member

m-vo commented Aug 22, 2020

In the meantime you can try running the commands yourself:

rm -rf var/cache/prod
vendor/bin/contao-console contao:install-web-dir --env=prod
vendor/bin/contao-console cache:clear --no-warmup --env=prod
vendor/bin/contao-console cache:clear --no-warmup --env=dev
vendor/bin/contao-console cache:warmup --env=prod
vendor/bin/contao-console assets:install web --symlink --relative --env=prod
vendor/bin/contao-console contao:install web --env=prod
vendor/bin/contao-console contao:symlinks web --env=prod

@toteph42
Copy link
Author

I entered all commands in sequence and they did not return any error messages. After that I tried to call my site. Unfortunately it ended up in a loop. So I started Contao Manager, which then told me I can either try to repair a defect installation or start Contao in save mode. var/log is empty
error.log

@fritzmg
Copy link
Contributor

fritzmg commented Aug 23, 2020

Unfortunately it ended up in a loop.

What do you mean by that?

@toteph42
Copy link
Author

Nach mehreren Minuten kommt: Beim Verbinden mit contao.localhost trat ein Fehler auf. PR_CONNECT_RESET_ERROR

@fritzmg
Copy link
Contributor

fritzmg commented Aug 23, 2020

Nach mehreren Minuten kommt: Beim Verbinden mit contao.localhost trat ein Fehler auf. PR_CONNECT_RESET_ERROR

That sounds unrelated to this problem or Contao itself.

@toteph42
Copy link
Author

Leider doch, da

<?php
declare(strict_types=1);

echo 'Hier ist Contao!'; exit;

in web\index.php funktioniert.

@aschempp
Copy link
Member

aschempp commented Sep 7, 2020

This is not a Contao Manager issue, but rather a problem of Contao itself. It might be solved in the latest version though (contao/contao#1964, contao/contao#2184)

@aschempp aschempp closed this as completed Sep 7, 2020
leofeyer pushed a commit to contao/contao that referenced this issue Jan 15, 2021
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes ... let's see 😉 
| Docs PR or issue | todo

Our `ScriptHandler` is currently running inside Composer which is problematic (see #1956, #1964, contao/contao-manager#582, contao/manager-bundle#88, ...) mostly due to the fact that we're then sharing Composer's already loaded 3rd party requirements in another/unpredictable version than we're requiring them.

Imo the only way to properly solve this is by using a dedicated binary (compare to  composer/composer#6738 (comment)). I previously thought this would not work because paths in the `composer.json` script section are not normalized and therefore only work in all OS but Windows or just in Windows depending on the type of slashes used. *But:* Composer pushes the `vendor/bin` dir [onto the PATH environment](https://getcomposer.org/doc/articles/scripts.md#writing-custom-commands) so it's possible to have a usage without any slashes. 😄 

That said, here is how this POC works:
* The `ScriptHandler` now works without a `Composer\Script\Event`. Unfortunately it cannot find out the original command flags or if the IO is decorated or not.
* It therefore allows passing additional flags that are appended to each executed command (like `--ansi`, `-vvv`).
* If you still call it from within Composer, a legacy routine kicks in, informs the user to change the script definition and starts a process with the new binary as a fallback.
* The binary simply requires the `autoload.php` and then calls the `ScriptHandler` and passes its arguments on as command flags.

The managed edition `composer.json` should be changed to this:
```json
    "scripts": {
        "post-install-cmd": [
            "contao-script-handler"
        ],
        "post-update-cmd": [
            "contao-script-handler"
        ]
    }
```

Note: I ignored the fact that there are other commands than `initializeApplication` for now. If we want to go down this route we should discuss the API of the binary (e.g. if it should allow calling individual bits). It should eventually go into the `core-bundle` then if it has a purpose outside the ME. Plus, there also is a another `ScriptHandler` in the `core-bundle`, which does not seem to be used anymore which we should probably take care of.

Commits
-------

8abcc0e add command to initialize application
ffb2de2 deprecate script handler + redirect to command
58bc88b improve testability
7db2650 add unit tests
cba6dd1 fix float conversion
9c8d14e fix return type annotation
8680777 fix unit tests under windows
7ed330d make yamllint happy
595bfed prepend php executable
0611b21 adjust timeouts
f17eab5 add more tests
b495095 simplify unit tests
24077c0 make web dir a relative path
b55d021 always purge cache (so that the new command will be found)
d7ec0ab use real console path instead of symlinked/proxy one
fa7deaa setup a script handler binary
6df4797 inline bootstrap.php
8b741ad drop unnecessary variable + type hint
a16ac29 CS
c5a6ca4 Merge branch 'master' into feature/script-handler-bin
8822e58 rename contao-script-handler to contao-setup
29b568b drop obsolete cache purge stage
2365edb re-add outputting 'contao:migrate' info
dfeb3f3 rename command
87c2019 drop filesystem usage in command (cache gets already purged in binary)
eddc067 fix type annotation
a5fa602 display startup errors when running with -vvv
34e1c41 adjust wording
c3750a8 Fix indentation

Co-authored-by: Martin Auswöger <martin@auswoeger.com>
2e06a6f use a closure for process creation
1b6d783 Merge branch 'feature/script-handler-bin' of github.com:m-vo/contao into feature/script-handler-bin
dd98b28 Adjust the deprecation messages
c4f0fb0 Update manager-bundle/src/Resources/config/commands.yml

Co-authored-by: Leo Feyer <github@contao.org>
845b0a0 drop obsolete usage statement
287776b fix createProcessHandler usage in tests
acce470 Do not prepend vendor/bin/ to the binary
0d6de31 fix the unit tests on windows
leofeyer pushed a commit to contao/manager-bundle that referenced this issue Jan 15, 2021
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes ... let's see 😉 
| Docs PR or issue | todo

Our `ScriptHandler` is currently running inside Composer which is problematic (see #1956, #1964, contao/contao-manager#582, #88, ...) mostly due to the fact that we're then sharing Composer's already loaded 3rd party requirements in another/unpredictable version than we're requiring them.

Imo the only way to properly solve this is by using a dedicated binary (compare to  composer/composer#6738 (comment)). I previously thought this would not work because paths in the `composer.json` script section are not normalized and therefore only work in all OS but Windows or just in Windows depending on the type of slashes used. *But:* Composer pushes the `vendor/bin` dir [onto the PATH environment](https://getcomposer.org/doc/articles/scripts.md#writing-custom-commands) so it's possible to have a usage without any slashes. 😄 

That said, here is how this POC works:
* The `ScriptHandler` now works without a `Composer\Script\Event`. Unfortunately it cannot find out the original command flags or if the IO is decorated or not.
* It therefore allows passing additional flags that are appended to each executed command (like `--ansi`, `-vvv`).
* If you still call it from within Composer, a legacy routine kicks in, informs the user to change the script definition and starts a process with the new binary as a fallback.
* The binary simply requires the `autoload.php` and then calls the `ScriptHandler` and passes its arguments on as command flags.

The managed edition `composer.json` should be changed to this:
```json
    "scripts": {
        "post-install-cmd": [
            "contao-script-handler"
        ],
        "post-update-cmd": [
            "contao-script-handler"
        ]
    }
```

Note: I ignored the fact that there are other commands than `initializeApplication` for now. If we want to go down this route we should discuss the API of the binary (e.g. if it should allow calling individual bits). It should eventually go into the `core-bundle` then if it has a purpose outside the ME. Plus, there also is a another `ScriptHandler` in the `core-bundle`, which does not seem to be used anymore which we should probably take care of.

Commits
-------

8abcc0e7 add command to initialize application
ffb2de27 deprecate script handler + redirect to command
58bc88bc improve testability
7db26501 add unit tests
cba6dd17 fix float conversion
9c8d14e6 fix return type annotation
8680777b fix unit tests under windows
7ed330df make yamllint happy
595bfed3 prepend php executable
0611b214 adjust timeouts
f17eab53 add more tests
b4950958 simplify unit tests
24077c04 make web dir a relative path
b55d0215 always purge cache (so that the new command will be found)
d7ec0ab6 use real console path instead of symlinked/proxy one
fa7deaa4 setup a script handler binary
6df47977 inline bootstrap.php
8b741ad4 drop unnecessary variable + type hint
a16ac29c CS
c5a6ca48 Merge branch 'master' into feature/script-handler-bin
8822e584 rename contao-script-handler to contao-setup
29b568be drop obsolete cache purge stage
2365edb9 re-add outputting 'contao:migrate' info
dfeb3f34 rename command
87c20190 drop filesystem usage in command (cache gets already purged in binary)
eddc067d fix type annotation
a5fa6022 display startup errors when running with -vvv
34e1c411 adjust wording
c3750a8e Fix indentation

Co-authored-by: Martin Auswöger <martin@auswoeger.com>
2e06a6ff use a closure for process creation
1b6d783e Merge branch 'feature/script-handler-bin' of github.com:m-vo/contao into feature/script-handler-bin
dd98b28b Adjust the deprecation messages
c4f0fb06 Update manager-bundle/src/Resources/config/commands.yml

Co-authored-by: Leo Feyer <github@contao.org>
845b0a05 drop obsolete usage statement
287776bc fix createProcessHandler usage in tests
acce470c Do not prepend vendor/bin/ to the binary
0d6de31a fix the unit tests on windows
AlexejKossmann pushed a commit to AlexejKossmann/contao that referenced this issue Apr 6, 2021
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes ... let's see 😉
| Docs PR or issue | todo

Our `ScriptHandler` is currently running inside Composer which is problematic (see contao#1956, contao#1964, contao/contao-manager#582, contao/manager-bundle#88, ...) mostly due to the fact that we're then sharing Composer's already loaded 3rd party requirements in another/unpredictable version than we're requiring them.

Imo the only way to properly solve this is by using a dedicated binary (compare to  composer/composer#6738 (comment)). I previously thought this would not work because paths in the `composer.json` script section are not normalized and therefore only work in all OS but Windows or just in Windows depending on the type of slashes used. *But:* Composer pushes the `vendor/bin` dir [onto the PATH environment](https://getcomposer.org/doc/articles/scripts.md#writing-custom-commands) so it's possible to have a usage without any slashes. 😄

That said, here is how this POC works:
* The `ScriptHandler` now works without a `Composer\Script\Event`. Unfortunately it cannot find out the original command flags or if the IO is decorated or not.
* It therefore allows passing additional flags that are appended to each executed command (like `--ansi`, `-vvv`).
* If you still call it from within Composer, a legacy routine kicks in, informs the user to change the script definition and starts a process with the new binary as a fallback.
* The binary simply requires the `autoload.php` and then calls the `ScriptHandler` and passes its arguments on as command flags.

The managed edition `composer.json` should be changed to this:
```json
    "scripts": {
        "post-install-cmd": [
            "contao-script-handler"
        ],
        "post-update-cmd": [
            "contao-script-handler"
        ]
    }
```

Note: I ignored the fact that there are other commands than `initializeApplication` for now. If we want to go down this route we should discuss the API of the binary (e.g. if it should allow calling individual bits). It should eventually go into the `core-bundle` then if it has a purpose outside the ME. Plus, there also is a another `ScriptHandler` in the `core-bundle`, which does not seem to be used anymore which we should probably take care of.

Commits
-------

8abcc0e add command to initialize application
ffb2de2 deprecate script handler + redirect to command
58bc88b improve testability
7db2650 add unit tests
cba6dd1 fix float conversion
9c8d14e fix return type annotation
8680777 fix unit tests under windows
7ed330d make yamllint happy
595bfed prepend php executable
0611b21 adjust timeouts
f17eab5 add more tests
b495095 simplify unit tests
24077c0 make web dir a relative path
b55d021 always purge cache (so that the new command will be found)
d7ec0ab use real console path instead of symlinked/proxy one
fa7deaa setup a script handler binary
6df4797 inline bootstrap.php
8b741ad drop unnecessary variable + type hint
a16ac29 CS
c5a6ca4 Merge branch 'master' into feature/script-handler-bin
8822e58 rename contao-script-handler to contao-setup
29b568b drop obsolete cache purge stage
2365edb re-add outputting 'contao:migrate' info
dfeb3f3 rename command
87c2019 drop filesystem usage in command (cache gets already purged in binary)
eddc067 fix type annotation
a5fa602 display startup errors when running with -vvv
34e1c41 adjust wording
c3750a8 Fix indentation

Co-authored-by: Martin Auswöger <martin@auswoeger.com>
2e06a6f use a closure for process creation
1b6d783 Merge branch 'feature/script-handler-bin' of github.com:m-vo/contao into feature/script-handler-bin
dd98b28 Adjust the deprecation messages
c4f0fb0 Update manager-bundle/src/Resources/config/commands.yml

Co-authored-by: Leo Feyer <github@contao.org>
845b0a0 drop obsolete usage statement
287776b fix createProcessHandler usage in tests
acce470 Do not prepend vendor/bin/ to the binary
0d6de31 fix the unit tests on windows
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

4 participants