I'm trying to figure out how Lazarus knows where to find the packages that are required for the project.
Beside what Marco and PascalDragon said, the low-level answer is that the IDE keeps a record of "known" packages in its configuration directory, in the file
packagefiles.xml, section "UserPkgLinks".
There is also a section in the project info file ("
project.lpi") called "RequiredPackages" where one might find an override, if set; for example:
<RequiredPackages Count="3">
<Item1>
<PackageName Value="LazWiki"/>
<DefaultFilename Value="lazwiki/lazwiki.lpk" Prefer="True"/>
</Item1>
<Item2>
<PackageName Value="CodeTools"/>
</Item2>
<Item3>
<PackageName Value="LazUtils"/>
</Item3>
</RequiredPackages>
(though in this case the exact same package is also stored in
packagefiles.xml)