snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.98k stars 3.16k forks source link

6.0.1 fails to run 'php artisan optimize' with Unable to prepare route [hardware/{assetId}/checkout] for serialization. Another route has already been assigned name [checkout/hardware]. #11163

Open davidbuzz opened 2 years ago

davidbuzz commented 2 years ago

Debug mode

Describe the bug

$ php artisan optimize Configuration cache cleared! Configuration cached successfully! Route cache cleared!

LogicException

Unable to prepare route [hardware/{assetId}/checkout] for serialization. Another route has already been assigned name [checkout/hardware].

at vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php:218 214▕ $route->name($name = $this->generateRouteName()); 215▕ 216▕ $this->add($route); 217▕ } elseif (! is_null($symfonyRoutes->get($name))) { ➜ 218▕ throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}]."); 219▕ } 220▕ 221▕ $symfonyRoutes->add($route->getName(), $route->toSymfonyRoute()); 222▕

  +30 vendor frames 

31 artisan:35 Illuminate\Foundation\Console\Kernel::handle()

Reproduction steps

  1. try to run artisan optimize
  2. ...

Expected behavior

it should run without error

Screenshots

No response

Snipe-IT Version

6.0.1

Operating System

ubuntu linux

Web Server

CLI

PHP Version

7.4

Operating System

n/a

Browser

n/a

Version

n/a

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

$ php artisan optimize
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!

   LogicException 

  Unable to prepare route [hardware/{assetId}/checkout] for serialization. Another route has already been assigned name [checkout/hardware].

  at vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php:218
    214▕             $route->name($name = $this->generateRouteName());
    215▕ 
    216▕             $this->add($route);
    217▕         } elseif (! is_null($symfonyRoutes->get($name))) {
  ➜ 218▕             throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}].");
    219▕         }
    220▕ 
    221▕         $symfonyRoutes->add($route->getName(), $route->toSymfonyRoute());
    222▕ 

      +30 vendor frames 
  31  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

Additional context

No response

welcome[bot] commented 2 years ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

uberbrady commented 2 years ago

Yeah, we should probably fix this - repeated route names probably are going to eventually break in some version of the framework.

BTW, why are you doing the optimize step? Just trying to get things to 'go faster' or is there something specific you're trying to do? (This is more from curiosity than anything else, of course)

snipe commented 2 years ago

I already have a branch in process to fix this. It was because of the Great Route Changes of Laravel 8. :( Not hard to do, but LOTS of places reference routes by name, so we have to be careful with testing.

uberbrady commented 2 years ago

Well, it sounds like php artisan optimize will be a great development tool for that! Hah :) I'll assign it to you then.

snipe commented 2 years ago

No, it won't - it will only check to see that the routes can be cached (and there are often lots of valid reasons they can't be, including constructors that do weird things). I mean testing the app, tits to toenails by testing to make sure we're not 500ing - it's going to be a bear.

krebbi commented 1 year ago

"clone/license" is also assigned in routes/web.php and in /routes/web/licenses.php

snipe commented 1 year ago

It’s a known issue (there are waaaay more than just that one). It’s kinda low priority though, since it’s not necessary to run the optimize command. When benched, it doesn’t offer that much