0

We are using API Platform to build our APP and we got stuck into a bug that looks environment related to us. We are 4 developpers, 3 of us under windows have the same issue while the one under mac os can't reproduice it and everything's working fine for him. We are working with the official docker and we all got it updated.

I've tried everything related I could find on google, checked the doc again and nothing has worked for us that's why I'm asking for your help.

Now let me explain whats's happening. We are on a branch, everthings is working fine, all our tests are working good with phpunit. And at some point when we create a new entity, the entity and repository files are generated, and after that, any command we could try (migration, make new entity, clear cache, testing with phpunit) will lead to that error :

Cannot autowire service "App\Command\CreateActionsCommand": argument "$roleRepository" of method "__construct()" references class "App\Repository\RoleRepository" but no such service exists.

I checked the RoleRepository, everything's is fine compared to the related documentation (https://symfony.com/doc/current/doctrine.html), also checked the services.yaml file, autowire should be able to access the repository file.

Something very weird we found while trying to debug, if we manually remove any random repository file, we are able to make to use commands again.

Here's my RoleRepository file:

<?php

namespace App\Repository;

use App\Entity\Role;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @method Role|null find($id, $lockMode = null, $lockVersion = null)
 * @method Role|null findOneBy(array $criteria, array $orderBy = null)
 * @method Role[]    findAll()
 * @method Role[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class RoleRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Role::class);
    }
}

Let me know if you need to know any details, thanks for your help !

Cortodev
  • 11
  • 2
  • 1
    If it works on Mac and not on Windows, I would suspect a capitalization error e.g. `A` vs. `a`. Make sure all your filenames and class names and namespaces have the correct case. IIRC, the Mac won't see the differences on git checkout (I think the Mac is case-insensitive on the filesystem - so `/myFoo` and `/myfoo` are the same to a Mac). – craigh Dec 21 '22 at 14:11
  • Might also be a caching problem of some sort? Does running `bin/console cache:clear` after creating a new entity help? Should not need to do so but mentioning Docker and Windows together is always a bit of a red flag. It's possible your var docker configuration is not quite right for Windows. – Cerad Dec 21 '22 at 15:22

1 Answers1

1

I cloned and installed the project in a debian VM and everything's working fine now. Windows and Docker issue it looks like.

Cortodev
  • 11
  • 2