symfony: Compile Error: require(): files, after cache:celar?

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 4.0

It seems flex and autol loading of vendor files sometimes breaks. Or i do not unrestand something.

I have installed clear skeleton, installed packages, it was working for some time, and that i got many errors kind of

Compile Error: require(): Failed opening required '/home/vagrant/Code/testsite/var/cache/dev/ContainerPRNapfp/srcDevDebugProjectContainer.php' (include_path='.:/usr/share/php')

(1/1) FatalErrorException

Compile Error: require_once(): Failed opening required '/home/vagrant/Code/testsite\vendor\symfony\framework-
bundle\Controller\ControllerNameParser.php' (include_path='.:/usr/share/php')

in srcDevDebugProjectContainer.php (line 93)
at srcDevDebugProjectContainer->__construct()
in srcDevDebugProjectContainer.php (line 13)

And so on, like, file is there, but autoloader can not see it. It starting after cache:clear command.

My composer.json

`{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "sensio/framework-extra-bundle": "^5.1",
        "sensiolabs/security-checker": "^4.1",
        "symfony/asset": "^4.0",
        "symfony/console": "^4.0",
        "symfony/flex": "^1.0",
        "symfony/framework-bundle": "^4.0",
        "symfony/lts": "^4@dev",
        "symfony/maker-bundle": "^1.0",
        "symfony/orm-pack": "^1.0",
        "symfony/security": "^4.0",
        "symfony/security-bundle": "^4.0",
        "symfony/security-core": "^4.0",
        "symfony/security-csrf": "^4.0",
        "symfony/security-guard": "^4.0",
        "symfony/security-http": "^4.0",
        "symfony/translation": "^4.0",
        "symfony/webpack-encore-pack": "^1.0",
        "symfony/yaml": "^4.0"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "symfony/dotenv": "^4.0",
        "symfony/profiler-pack": "^1.0"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
            "security-checker security:check": "script"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "id": "01C0BB1E3KRM232JHH1TE3TYKV",
            "allow-contrib": false
        }
    }
}
`

Remove folder cahe, it is fine, but after clearing cache, everything breaks, can not autoload files.

php bin/console cache:clear

And project is down.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 31 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Your report shows that the code is using “require”, which is not the case anymore in more recent version. You should upgrade to v3.4.2 And you might need to clear the cache using “rm var/cache/*” instead of cache:clear

I’ve been having the same issue with 3.4/4, but I’m running it from a Command that gets triggered when doing a git push.

Rough example: class UpdateCommand extends ContainerAwareCommand system('php bin/console cache:clear --env=prod --no-warmup --no-debug');

or even with a: exec('./go-live.sh')

which then runs php bin/console cache:clear --env=prod --no-debug --no-warmup; php bin/console cache:warmup --env=prod