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

Warning appears if multiple namespaces contain the same custom Composer script name #60

Closed
halloei opened this issue Nov 24, 2021 · 2 comments · Fixed by #96
Closed

Comments

@halloei
Copy link

halloei commented Nov 24, 2021

If multiple namespaces contain a custom Composer script in their composer.json which have the same name, the following warning is triggered while executing composer bin all install: A script named <script name> would override a Composer command and has been skipped

Steps to reproduce:

Add two tools in different namespaces:

composer bin phpcs require squizlabs/php_codesniffer
composer bin phpunit require phpunit/phpunit

Take this script

"scripts": {
    "foo": ""
}

and append it to both composer.json:

vi vendor-bin/phpcs/composer.json 
vi vendor-bin/phpunit/composer.json

Finally run the command to install the dependencies of all namespaces:

composer bin all install

Output:

root@a59f18950fef:/app# composer bin all install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating autoload files
A script named foo would override a Composer command and has been skipped
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating autoload files
26 packages you are using are looking for funding.
Use the composer fund command to find out more!

@theofidry
Copy link
Collaborator

That is correct. The only way to "fix" this is to specify an order in which the bin directories should be installed but even so I'm not sure it would 100% work. For example if you have:

namespace1
codesniffer <- the main you want
phpstan <- because it's a dep, not because you are interested in
namespace2
phpstan <- the one you want

in this case even if namespace1 is guaranteed to be installed first (because you would have an option to), the symlink for phpstan would not be the one you want.

This is why I highly recommend to disable symlinks. The path to pick is a bit less convenient but it completely avoids this sort of problem.

@halloei
Copy link
Author

halloei commented Jan 13, 2022

I've disabled symlinks from the beginning I started working with Composer Bin Plugin. But the warning mentioned above appears nevertheless:

Main composer.json:

"extra": {
    "bamarni-bin": {
        "bin-links": false
    }
}

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

Successfully merging a pull request may close this issue.

2 participants