Skip to content

Build dir is different on subsequent runs of composer install #46324

Closed
@vudaltsov

Description

@vudaltsov

Symfony version(s) affected

6.0.8

Description

I have a custom build dir:

public function getBuildDir(): string
{
    return $this->getProjectDir().'/var/build/'.$this->environment;
}

I've noticed that sometimes debug:container --deprecations fails with The deprecation file does not exist, please try warming the cache first. due to different build dir. I managed to reproduce this only when running composer install.

How to reproduce

s new --dir symfony_build_dir_problem
cd ./symfony_build_dir_problem
echo '<?php

namespace App;

use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    public function getBuildDir(): string
    {
        return $this->getProjectDir()."/var/build/".$this->environment;
    }
}' > ./src/Kernel.php
composer install -q
grep 'kernel.build_dir' var/build/dev/App_KernelDevDebugContainer.xml
composer install -q
grep 'kernel.build_dir' var/build/dev/App_KernelDevDebugContainer.xml

The result will be:
/Users/vudaltsov/PhpProjects/happy-inc/server/.stuff/test/symfony_build_dir_problem/var/build/dev
/Users/vudaltsov/PhpProjects/happy-inc/server/.stuff/test/symfony_build_dir_problem/var/cache/dev

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions