contao / core-bundle

[READ-ONLY] Contao Core Bundle
GNU Lesser General Public License v3.0
122 stars 57 forks source link

Log file symlink fails on Windows 10 #634

Closed bezin closed 7 years ago

bezin commented 7 years ago

Hi there, I just updated a local Contao 4.2 version to 4.3 via Composer. Unfortunately, the symlink command fails when trying to symlink the logs folder:

ERROR   system/logs  Failed to create symbolic link from "C:\development\web\vhosts\contao4-basic\C:\development\web\vhosts\contao4-basic\app\logs" to "C:\development\web\vhosts\contao4-basic\system\logs".

Apparently, the first path is malformed, because it has the root dir in it twice. I am not very comfortable with Symfony console commands to debug it myself yet, but I'll be of any assistance, if neccessary :)

Cheers!

leofeyer commented 7 years ago

What does your composer.json look like?

bezin commented 7 years ago
{
    "name": "contao/standard-edition",
    "type": "project",
    "description": "Contao Open Source CMS",
    "license": "LGPL-3.0+",
    "authors": [
        {
            "name": "Leo Feyer",
            "homepage": "https://github.com/leofeyer"
        }
    ],
    "require": {
        "php": ">=5.5.0",
        "symfony/symfony": "~2.8|~3.0",
        "symfony/monolog-bundle": "~2.8",
        "symfony/swiftmailer-bundle": "~2.3",
        "sensio/distribution-bundle": "~5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "doctrine/doctrine-bundle": "~1.6",
        "lexik/maintenance-bundle": "~2.0",
        "contao/contao": "^4.2.3",
        "incenteev/composer-parameter-handler": "~2.0"
    },
    "autoload": {
        "classmap": [
            "app/AppCache.php",
            "app/AppKernel.php"
        ]
    },
    "config": {
        "preferred-install": {
            "contao/*": "source",
            "contao-components/*": "source",
            "*": "dist"
        },
        "component-dir": "assets"
    },
    "extra": {
        "branch-alias": {
            "dev-develop": "4.3.x-dev"
        },
        "incenteev-parameters": {
            "file": "app/config/parameters.yml",
            "env-map": {
                "secret": "CONTAO_RANDOM_SECRET"
            }
        },
        "symfony-bin-dir": "app",
        "symfony-var-dir": "app",
        "symfony-assets-install": "relative"
    },
    "scripts": {
        "post-install-cmd": [
            "Contao\\CoreBundle\\Composer\\ScriptHandler::generateRandomSecret",
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Contao\\CoreBundle\\Composer\\ScriptHandler::addDirectories",
            "Contao\\CoreBundle\\Composer\\ScriptHandler::generateSymlinks"
        ],
        "post-update-cmd": [
            "Contao\\CoreBundle\\Composer\\ScriptHandler::generateRandomSecret",
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Contao\\CoreBundle\\Composer\\ScriptHandler::addDirectories",
            "Contao\\CoreBundle\\Composer\\ScriptHandler::generateSymlinks"
        ]
    }
}
leofeyer commented 7 years ago

Is there more than the error message from your initial post? A stack trace maybe?

bezin commented 7 years ago

Nope. I just checked again: I run php app/console contao:symlinks in the project root and all I get is an ok for system/themes/flexible, web/assets and web/system/themes and the error mentioned in the opening post.

leofeyer commented 7 years ago

Can anyone with a Windows machine please try to debug this?

bezin commented 7 years ago

This was actually quite an easy catch:

contao\core-bundle\src\Command\SymlinksCommand.php:111-114

// $this->rootDir = 'C:\development\web\vhosts\contao4-basic'
// $this->getContainer()->getParameter('kernel.logs_dir') = 'C:\development\web\vhosts\contao4-basic\app\logs'

$this->symlink(
            str_replace($this->rootDir.'/', '', $this->getContainer()->getParameter('kernel.logs_dir')),
            'system/logs'
        );

The trailing slash leads to str_replace failing, hence the root dir dos not get replaced by '' and hence, the double path.

leofeyer commented 7 years ago

Fixed in 498a6f2b5d28e2e4af6ddfffb8bf41a5c5f6f2ca.

fkaminski-dev commented 7 years ago

Hi, hatte den gleichen Fehler unter Windows 7. Wenn ich die SymlinksCommand.php aus 498a6f2 benutze erhalte ich nicht die explizite Fehlermeldung sondern es wird nur noch die Contao Fehlerseite aufgerufen mit dem Hinweis auf den Ordner app/logs der nicht existiert ...

fritzmg commented 7 years ago

mit dem Hinweis auf den Ordner app/logs der nicht existiert ...

Wie hast du Contao 4.3 installiert? Wenn du eine frische Installation gemacht hast lautet der Ordner /var/logs.

fkaminski-dev commented 7 years ago

Ja, vollständige Neuinstallation via domain/install.php ...

fritzmg commented 7 years ago

Siehe https://github.com/contao/core-bundle/issues/641 - der Ordner heißt jetzt /var/logs.

fkaminski-dev commented 7 years ago

Gerade nochmal neu installiert: Aus /var/logs Eintrag:

[2016-12-02 11:01:43] request.INFO: Matched route "contao_install". {"route":"contao_install","route_parameters":{"_scope":"backend","_token_check":true,"_controller":"Contao\\InstallationBundle\\Controller\\InstallationController::installAction","_route":"contao_install"},"request_uri":"http://contao4.dev4/contao/install","method":"GET"} []
[2016-12-02 11:01:44] app.CRITICAL: An exception occurred. {"exception":"[object] (Symfony\\Component\\Filesystem\\Exception\\IOException(code: 0): Failed to remove directory \"C:\\__WEBDEV__SITES__\\contao4\\htdocs\\var\\cache\\prod/..\\prod\\annotations\\ee\": rmdir(C:\\__WEBDEV__SITES__\\contao4\\htdocs\\var\\cache\\prod/..\\prod\\annotations\\ee): Directory not empty. at C:\\__WEBDEV__SITES__\\contao4\\htdocs\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Filesystem\\Filesystem.php:176)"} []
fritzmg commented 7 years ago

Nachdem du den Fix eingespielt hast, musst du den Production Cache löschen.

fkaminski-dev commented 7 years ago

Ich habe vorher alles gelöscht - Datenbank, htdocs Verzeichnis etc..

fritzmg commented 7 years ago

Du musst, nachdem du den Fix eingespielt hast den Production Cache löschen. Bspw. mit

bin/console cache:clear --env=prod

oder manuell den Ordner /var/cache/prod löschen. Hast du das gemacht?

fkaminski-dev commented 7 years ago

Ich habe in ein neues/leeres Verzeichnis entpackt / den Fix eingespielt / dann die install.php aufgerufen ...

Aber auch ein Aufruf: php bin/console cache:clear --env=prod

oder manuell das Verzeichnis löschen

änderte nichts ...

( Windows 7 / Xampp PHP Version 5.6.11 / CGI/FastCGI )

fritzmg commented 7 years ago

Jemand im Forum hat grundsätzlich das selbe Problem: https://community.contao.org/de/showthread.php?64865-4-3-0-Installation-unter-Win7-fehlgeschlagen-(Directory-not-empty) Bei mir konnte ich es noch nicht reproduzieren. Ich warte zuerst mal auf den release von contao/installation-bundle 1.2.1 und contao/core-bundle 4.3.1.