-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Order of installed_paths
inconsistent between runs
#125
Comments
Hi! Thank you for bringing this to our attention! This seems to be one of these edge cases we didn't think about when the plugin was created, but it indeed seems like a valuable improvement to the current logic. We'll have to verify that the plugin has control over setting the order of the paths. I can't give you a time-table when this will be picked up, but I am in favor of implementing this! |
I created a PR (#126) that should fix this. |
@kevinfodness Thank you very much for your contribution! The changes from #126 have been merged to |
Thanks! Glad to help. |
Just for context: |
@kevinfodness Thanks for bringing this to our attention and for the fix. While it fixes the immediate issue of the cache invalidation in PHPCS, it doesn't fix the underlying problem. I've been trying to figure out where the underlying race condition occurs, so we can report it to the Composer project. Unfortunately I haven't been able to reproduce the issue locally which makes debugging kind of hard. If anyone wants to look into this further - there's an easy way to see whether the race condition still exists as the plugin shows a status message if the Basically with the race condition, the following will be displayed at the end of each install (same message each time now the paths are sorted on save):
... while if the race condition would not exist, the plugin would stay silent on subsequent runs, or if running with @kevinfodness Would you mind checking if you still see the /cc @Seldaek |
I'll do what I can. Do you mean running I suspect that the issue here may be related to the fact that this is running in a Travis CI container and that we're caching Composer dependencies in Travis via caching the |
Yes, exactly. I'll be sending in a PR in a moment with another tiny change as well which may or may not be related to/fix this issue. |
Interesting - it does trigger. I'm running my Travis CI job in debug mode to test it out. My
Note that we aren't committing a lock file to the repo, but one was created during the initial |
Actually, my |
OK, that's actually a feature of my before_script, not a bug - I'm checking to see whether there are any files that changed that would need to be run through phpcs before installing it, and in the PR I'm debugging, there aren't, so it skips the install. I've got a |
I'm noticing that the order of lock/download/install operations from Composer seems to be consistent between runs, but the order in which the standards were added (prior to my patch) did not match the order that Composer was reporting installing the standards. Is it possible that Composer is running some of these operations async? |
@kevinfodness Thanks for testing. Whether or not there is a Example output of a local run I did after manually deleting the Note that the |
I honesty don't know.... anyone ? |
In my use case, since the Travis CI container is created fresh each time the job runs, there are no |
I think I have an answer on the async - if I'm reading this code correctly, then Composer is running operations async, and the order in which the post-install hooks get added depends on when the packages install, which is itself an async operation: So, in cases where the packages aren't installed, Composer is installing them, and creating the array of |
@kevinfodness thanks for looking into this deeper!
I must be missing something obvious, but if the AFAICS, it is only if If this plugin would run before all installs are finished, it could potentially miss standards if that particular package wouldn't have finished installing, which would be the more severe error condition. Edit: hang on... ok, so I think I may have it. With async running, the order of the packages as returned by |
Yep—I don't know all of the Composer internals, but something inherent to the async workings of Composer that would cause the order of the packages to be different on a first, fresh install, like in a CI environment, as you said. |
Sooo.. yes indeed the order of packages in the local repository is not guaranteed. It is sorted by name on write though to make sure the installed.json does not change between runs/machines so when reloading it it would be guaranteed, but while it's installing packages it's not sorting them because nobody ever cared. If you need this in a given order, I'd suggest sorting the paths or the packages yourself so you are sure the order will be what you want always. |
@Seldaek Thanks for confirming and that's exactly the solution which was pulled by @kevinfodness and has been merged. I think we can safely conclude based on the above discussion and confirmation that there is indeed no race condition, which was what the "digging deeper" above was trying to investigate/confirm/deny. So, all is good 👍 |
Thanks for looking into this further @jrfnl and @kevinfodness! I was planning on doing a follow-up, but you all saved me a lot of time (which is still a bit scarce). And thank you @Seldaek for your confirmation on this. I know how busy you are, your insights are much appreciated! |
|
Thanks for pointing that out! I've still not recovered the muscle-memory from my fingers 100% when typing. Fixed now. 👍 |
@Potherca No worries 😉 |
Problem/Motivation
Expected behaviour
Actual behaviour
Steps to reproduce
Proposed changes
Environment
Output of
vendor/bin/phpcs --config-show
:Contents of CodeSniffer.conf:
Tested against
master
branch?master
branch.I have not verified this against the master branch, but looking at the diff between 0.7.0 and the current HEAD, there shouldn't be anything in that diff that would affect this issue.
The text was updated successfully, but these errors were encountered: