Getting an error with kirby cli

Hello there!

I’ve been building a kirby site for a few weeks now and had installed and used the kirby cli a few days ago. Now suddenly when I run the cli, I get:

PHP Fatal error:  Cannot declare class Site, because the name is already in use in /Users/mrunkel/Projects/kautionsfrei/kirby/kirby/branches/default.php on line 16
PHP Stack trace:
PHP   1. {main}() /Users/mrunkel/.composer/vendor/getkirby/cli/kirby:0
PHP   2. Symfony\Component\Console\Application->run() /Users/mrunkel/.composer/vendor/getkirby/cli/kirby:59
PHP   3. Symfony\Component\Console\Application->doRun() /Users/mrunkel/.composer/vendor/symfony/console/Application.php:125
PHP   4. Symfony\Component\Console\Application->doRunCommand() /Users/mrunkel/.composer/vendor/symfony/console/Application.php:224
PHP   5. Kirby\Cli\Command\Clear\Cache->run() /Users/mrunkel/.composer/vendor/symfony/console/Application.php:888
PHP   6. Kirby\Cli\Command\Clear\Cache->execute() /Users/mrunkel/.composer/vendor/symfony/console/Command/Command.php:262
PHP   7. Kirby\Cli\Command\Clear\Cache->kirby() /Users/mrunkel/.composer/vendor/getkirby/cli/src/Command/Clear/Cache.php:27
PHP   8. Kirby->site() /Users/mrunkel/.composer/vendor/getkirby/cli/src/Command.php:161
PHP   9. include_once() /Users/mrunkel/Projects/kautionsfrei/kirby/kirby/kirby.php:548

Fatal error: Cannot declare class Site, because the name is already in use in /Users/mrunkel/Projects/kautionsfrei/kirby/kirby/branches/default.php on line 16

Call Stack:
    0.0003     381640   1. {main}() /Users/mrunkel/.composer/vendor/getkirby/cli/kirby:0
    0.0169    1890224   2. Symfony\Component\Console\Application->run() /Users/mrunkel/.composer/vendor/getkirby/cli/kirby:59
    0.0256    2209616   3. Symfony\Component\Console\Application->doRun() /Users/mrunkel/.composer/vendor/symfony/console/Application.php:125
    0.0257    2209616   4. Symfony\Component\Console\Application->doRunCommand() /Users/mrunkel/.composer/vendor/symfony/console/Application.php:224
    0.0257    2209616   5. Kirby\Cli\Command\Clear\Cache->run() /Users/mrunkel/.composer/vendor/symfony/console/Application.php:888
    0.0260    2214704   6. Kirby\Cli\Command\Clear\Cache->execute() /Users/mrunkel/.composer/vendor/symfony/console/Command/Command.php:262
    0.0260    2214768   7. Kirby\Cli\Command\Clear\Cache->kirby() /Users/mrunkel/.composer/vendor/getkirby/cli/src/Command/Clear/Cache.php:27
    0.0294    2848160   8. Kirby->site() /Users/mrunkel/.composer/vendor/getkirby/cli/src/Command.php:161
    0.0308    3030960   9. include_once('/Users/mrunkel/Projects/kautionsfrei/kirby/kirby/branches/default.php') /Users/mrunkel/Projects/kautionsfrei/kirby/kirby/kirby.php:548

Now, I’ve only been working with templates and patterns and haven’t touched the core code at all, so I can’t imagine what is is that I’ve done to cause this. I’ve already searched through my code to see if I’m being dumb and define $site somewhere, but I can’t find it.

Any pointers?

What was the command you used when this error occurred?

I believe it was clear:cache but it does it for all of them as long as I give a valid command. (ie, kirby by itself works, but kirby clear:cache doesn’t, neither does kirby make:user). kirby make:template does work, but I’m guessing because that never instantiates kirby.

Hm, I have no idea. What if you create a new project and use the Kirby CLI with that new project? Have you tried to replace the Kirby and Panel folders with fresh copies?

I have not, but I’ll give it a shot when I have a moment. At present, it’s not a deal breaker, just annoying so it will have to wait.

I was hoping someone else had seen this and would be like “yeah, check blah blah…”

Thanks for your time.

m.

Are you in your project’s root directory? - and not in a sub-folder, like the /kirby folder inside it?

This path looks a bit strange…

Projects/kautionsfrei/kirby is the root of the project.

Hmm. Ok, so I’m working from a different computer today and the cli runs without issue, so it’s definitely a personal problem.

If I uncover something specific with the other system, I’ll post it here.