Closed rogiervandongen closed 8 months ago
After some investigation, the problem is clear.
Running grunt ignorefiles creates phpcs.xml and one if the first lines there refers to.... ./.phpcs.xml.dist
There is no such dot file in Moodle. What is present is the file without the dot (./phpcs.xml)
Hi @rogiervandongen ,
I'm a little bit confused.
phpcs.xml.dist
file.npm ci && npx grunt ignorefiles
only creates the phpcs.xml
file (with all the ignores).phpcs.xml
), includes the former (phpcs.xml.dist
).
<rule ref="./phpcs.xml.dist"/>
So it seems that not "dot" file is involved at all. I remember that we made some changes about which files called to which files, because the dotted/not dotted combinations were multiple. And finally decide to got with the "not dotted" alternative.
Maybe your git clone has some old file, or maybe you've not re-installed (npm ci
) the tools recently and they are still generating old contents?
Ciao :-)
Hi @stronk7
This was indeed an older environment that was upgraded to The version as indicated above.
Everything was followed by a rather "default" install of the needed tools (aka npm install, so no npm ci involved here) Then I simply ran _nvm use__ followed by "grunt amd -f". This will auto-generate "phpcs.xml" (checked & confirmed).
Checking the contents of this generated file, for some reason it kept on refering to ./.phpcs.xml.dist I was 100% sure every "grunt amd -f" run would auto-generate this file again (which was in fact checked and correct).
Seeing your response, I decided to only leave the file that ships with Moodle and remove all other variations. Ran grunt amd -f again from the plugin folder and was rather shocked to see this actually generated the new file but now without the dot file i mentioned. The ref element now refers to the correct ./phpcs.xml.dist".
I'm somewhat baffled by the fact I needed to remove the file to get everything in working order, even when it was re-generated on every grunt run before (but with the wrong reference, or did it only "touch" the file so the timestamp would be updated but the file wasn't actually regenerated?). This is far from logical and IMO, impossible.
By the way: there were no updates or re-installs using npm of any kind since I filed this issue yesterday. However, removal of every variant of the phpcs file except the one shipped with Moodle magically fixed everything! It was also only after filing this issue that I saw there was a tracker issue involved (and the fixes were described in it).
My addition to this issue literally was 10 minutes before the end of the working day. I decided to not investigate it further and just wait for a response in the hope it'd provide some insight. It did, although not by re-installing or updating the CI, but by removing all "other" phpcs files.
Thanks for your response, you can now consider this a non-issue (although maybe it would be worth mentioning somewhere on the Moodle dev docs that removing all phpcs files except the Moodle distributed one may be a solution if anyone else should walk into a similar issue).
Cheers! :)
Hi @rogiervandongen ,
as said (and for the records), I think that the problem that you were experiencing was caused because of having installed an "old" node/grunt scripts (or some leftover .phpcs.xml
file).
Just looking to the order of affairs, they are as follow:
.phpcs.xml.dist
and grunt generated the .phpcs.xml
one. So, initially, we were using the "dotted" ones.phpcs.xml.dist
and grunt is generating the phpcs.xml
one (and devs can use the dotted ones, that have precedence, if they want to).So, in your case, my theory, is that, between May 2022 and December 2022, you ran npm install
, which grunt script was using the original "dotted" files. Later, after December 202, you updated your clone but did not update your nodejs/grunt installation (the best way to do so is to run npm ci
when needed, because it does the removal and reinstallation all-together), so it still was generating the, now wrong, dotted files.
Or, in case you had already reinstalled properly the nodejs stuf... then... maybe... you still had the old (dotted) .phpcs.xml
file around and, as far as they take precedence over the non-dotted (phpcs.xml
) one... it now was pointing to non-existing .phpcs.xml.dist
file.
In any case, I think that I'm going to close this, it's old stuff, and if anybody else faces this, all that is needed is to delete any dotted .phpcs.xml
file that may be there from the past.
Ciao :-)
Default install, v5.0.4, build 2024012600
Cannot use the code checker at all anymore, it just dies with this message for every file.
Moodle: 4.3+ Build: 20231013 PHP 8.1.27 (FPM/FastCGI)