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

bin/composer-unused not working when composer/composer not present #250

Closed
icanhazstring opened this issue Dec 17, 2021 · 13 comments
Closed
Labels
bug Something isn't working

Comments

@icanhazstring
Copy link
Member

Describe the bug

Currently composer/composer is used to "fake" a composer executable using the bin/composer-unused binary.
This is not possible anymore as the dependency to it was moved to dev to avoid conflicting while installing the tool.

The binary should be removed altogether an only bundled with the phar archive where composer/composer is shipped with.
If installed as plugin composer unused should be the way to go.

@icanhazstring icanhazstring added the bug Something isn't working label Dec 17, 2021
@icanhazstring icanhazstring changed the title Remove composer/composer dependency from binary Remove binary for composer plugin installations Dec 17, 2021
icanhazstring referenced this issue Dec 17, 2021
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
@icanhazstring
Copy link
Member Author

Will probably try to introduce a backward compatible change to the binary to avoid releasing 0.8 only for that.
This will check if the needed classes for the binary are present when executing it. Maybe I can fall back to using composer unused using symfony/process then.

@icanhazstring icanhazstring changed the title Remove binary for composer plugin installations bin/composer-unused not working when composer/composer not present Dec 17, 2021
@AndreasA
Copy link

@icanhazstring I actually use the composer bin plugin to install it, so I can have a fixed version and do not need to manually download it. This means I really would prefer the binary to be installed in the future too as it is kind of tricky to load the plugin inside a plugin for the original root composer.json

@icanhazstring
Copy link
Member Author

@AndreasA already working on a backward compatible fix right now.
In the future I will try and change something up, will probably remove the tight coupling with composer, and provide a separate plugin which integrates composer-unused as a composer plugin.

See #251

@AndreasA
Copy link

AndreasA commented Dec 17, 2021

@icanhazstring Ok. so a separate binary will still be available in the future too and not only as composer plugin?

@icanhazstring
Copy link
Member Author

Yes, probably going to integrate symfony/console directly, and adding a new command into composer/console

@icanhazstring
Copy link
Member Author

@AndreasA as you are using bin/composer-unused can you validate the change I made in #251 ?

@AndreasA
Copy link

@icanhazstring During installation with composer, if I switch to the fix branch in the require section, I get bin/composer-unused file not found in package. Not really sure why though

@AndreasA
Copy link

@icanhazstring OK. If I switched the preferred-install to src for the package it worked, maybe the file is ignored in gitattributes or similar?

however, I get a TypeError that the first argument of symfony process must be an array but a string is given. Maybe you want to use fromShellCommandline instead? I think it depends on which version of symfony/process is used though.

@AndreasA
Copy link

AndreasA commented Dec 18, 2021

@icanhazstring OK. If I use fromShellCommandline it goes one step further but in combination with the composer bin plugin it will fail as Command "unused" is not defined. is returned then. As the unused command/plugin is only registered in the vendor-bin namespaced composer.json.

This can be bypassed by starting it from the corresponding subdirectory but then the wrong directory / composer.json is analyzed regarding unused dependencies and I don't think there is an easy solution to specifying a different composer.json to be analyzed?

@icanhazstring
Copy link
Member Author

Not as easy tho.
Can you give me a clue about the project setup you are trying to run this tool against?

@AndreasA
Copy link

Well there is basically:

  • composer.json --> root project one
  • vendor-bin/composer-unused/composer.json --> composer.json for unused dependency check added using composer bin plugin with the composer-unused namespace.
  • src/ --> contains sources defined in the root composer.json autoload
  • bin/vendor/composer-unused --> link created for composer unused binary by the bin plugin.

Now I want to run the command bin/vendor/composer-unused against the root project composer.json and the src directory.

maybe also a bug in composer bin plugin because the unused plugin is not available through the composer bin plugin namespace.

It was working fine with 0.7.9. I guess it also might work, if I add composer/composer as dependency to the vendor-bin/composer-unused/composer.json.

I think the only permanent solution would be to make the unused plugin available as symfony console command or similar, instead of a plugin at all.

@icanhazstring
Copy link
Member Author

icanhazstring commented Dec 22, 2021

Thanks for your feedback.
I have released a 0.7.11 which reverts previous changes.

Will create a new issue, pointing to this to remove dependency on composer/composer

@icanhazstring
Copy link
Member Author

Starting with 0.8 the requirement to composer/composer is removed.
As mentioned here (already fixed in PR) #252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants