Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An argument with name "class" already exists. #36557

Closed
code2prog opened this issue Mar 11, 2021 · 15 comments
Closed

An argument with name "class" already exists. #36557

code2prog opened this issue Mar 11, 2021 · 15 comments

Comments

@code2prog
Copy link

  • Laravel Version: 8.32.1
  • PHP Version: 7.4.16
  • Database Driver & Version: -

Description:

After upgrade laravel/framework from v. 8.31.0 to 8.32.1 throw error in console An argument with name "class" already exists. after dump-autoload. Reverting to a previous version fixes the problem

Steps To Reproduce:

composer upgrade laravel/framework

@driesvints
Copy link
Member

I'm pretty sure that this is caused by #36513 but I don't see how that's breaking. Are you modifying the command in any way? We'll need a lot more info here. How are you calling your seeder classes? Are there internal artisan calls in your code/tests?

/cc @jasonmccreary

@code2prog
Copy link
Author

@driesvints I didn't change anything. The only thing that might have to do with it is tenancy/multi-tenant. But this package was not updated at the same time

@driesvints
Copy link
Member

@code2prog ah I wasn't asking if you changed anything. I'm asking how you're calling the db:seed command.

@code2prog
Copy link
Author

tenancy/multi-tenant#988
It seems that here is the reason

@jasonmccreary
Copy link
Contributor

jasonmccreary commented Mar 11, 2021

@driesvints, if you're worried about conflicts with community packages, we could try to rename it to seeder. But what's to say another package doesn't call it that. 🙃

@driesvints
Copy link
Member

Not entirely worried, was just wondering how your change broke certain use cases.

@driesvints
Copy link
Member

In general that wasn't part of the public API. If people are overwriting it in that way then we can't protect against that.

@jonquintero
Copy link

That is not true at all, rather this new change overwritten something and broke a package

@driesvints
Copy link
Member

@jonquintero we can't control the ways in how someone overwrites this. If you're overwriting a command and adding arguments of your own then you should be aware that an upstream change can break it. This is different from, for example, method signatures which are part of the public API of a codebase.

@jonquintero
Copy link

@driesvints I understand your point and it is totally valid, but my point is that this new change #36513 overwritten something that the mentioned package had been using for a long time and broke it, reverting to a previous version fixes the problem (8.31.0). What's great about all this? That forces developers to update their packages and not forget about them

@driesvints
Copy link
Member

@jonquintero you can't expect us to keep in mind every single way someone overwrites something in the framework. If we had to do that we had to do new major releases each week just to make sure that no small change breaks something in a third party app.

@jonquintero
Copy link

jonquintero commented Mar 12, 2021

@driesvints I know and you are right, that what I said: What's great about all this? That forces developers to update their packages and not forget about them

@driesvints
Copy link
Member

ah sorry, I misunderstood you there 👍

@ArlonAntonius
Copy link

Tbh, I really hope Laravel is not gonna think too much about community packages and all the stuff they do; would be a mess and they would not be able to add anything anymore to the ecosystem.

The PR they did was perfect, it's simply up to us to fix the package, thanks for finding this problem and taking the time to investigate and discuss this topic 🙏

@fulopattila122
Copy link

fulopattila122 commented Mar 12, 2021

For the sake of reference, I'm adding here another constellation that breaks.

tl;dr: Upgrading stancl/tenancy to 3.4.2 solves the problem

I'm having the same error, without having tenancy/multi-tenant installed.
I have another similar package though, stancl/tenancy - v3.4.0.

Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading laravel/framework (v8.29.0 => v8.32.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Downloading laravel/framework (v8.32.1)
  - Upgrading laravel/framework (v8.29.0 => v8.32.1): Extracting archive
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

                                                 
  An argument with name "class" already exists.  
                                                 

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants