Referring to this thread: Xelatex vs Lualatex relatively to PetiteCaps
I solved the problem by proceeding as follows:
I kept both the Texlive version of EB Garamond (/usr/local/texlive/2021/texmf-dist/...) and the one, most recent, I installed by myself (/usr/local/share/fonts/...) ;
I cleared the cache of /var/cache/fontconfig/;
I deleted ~/.texlive2021;
I regenerated the cache with fc-cache -sfv.
At this point, Xelatex compiles in any case with the Texlive version: in fact the log file (compilation performed with the \ XeTeXtracingfonts = 1 option):
Requested font "EB Garamond / OT: script = latn; language = dflt;" at 10.00002pt -> /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/EBGaramond-Regular.otf
The same code, compiled with Luatex, instead uses my more recent version:
avail lists: 1: 1,2: 56,3: 12,4: 1,5: 23,6: 6,7: 194,9: 26,11: 20 </usr/local/share/fonts/opentype/EBGaramond/EBGaramond-Regular.otf>
Now the example file compiles correctly, with the PetiteCapital, with both compilers. What I still don't understand is why the two compilers use files in different directories without any indication.
In fact, I observe that, with the font cache regenerated - and without ~/.texlive2021 in my HOME - Xelatex starts immediately and compiles, while Lualatex first creates (with a few seconds of work) its own cache in ~/.texlive2021 and only then starts the compilation of the .tex file.
It would be interesting to know where the PATH indication, that the two compilers follow to manage the fonts, resides and the reasons for this different behavior .