There is a very tricky compiler and IDE issue in Delphi 10.2 and up that on the compiler site behaves differently from Delphi 1.10.1 Berlin, and on the IDE side stays the same from Delphi 2005 on.
The issue baffled me, as lot’s features were not added in the Delphi compiler because of backward compatibility reasons.
The problem is that the compiler now favours the unit search path over the paths specified in the .dpr. This breaks compatibility with earlier versions and the IDE: the IDE still thinks pathnames in the .dpr files are the ones to follow.
There are some permutations on this problem, of which a few ones below.
Nonexisting unit in the project, but existing on the search path
- .dpr file in a directory X
- a unit inside a different directory A specified the .dpr file, but not on disk, and directory A not in the unit search path
- a disk version of the unit in yet another directory B where directory B is in the unit search path
This results in Delphi 1..10.1 Berlin to error on compiling the project (because the unit is not found), but 10.2 and up succeeding (because the unit is found).
Existing unit in the project, but directory not on the search a path
Another permutation is this one:
- .dpr file in a directory X
- a unit inside a different directory A specified the .dpr file, and on disk, and directory A not in the unit search path
Two same named units, one on search path, other in project but not on search path
Yet another permutation:
- .dpr file in a directory X
- a unit inside a different directory A specified the .dpr file, on disk, and directory A not in the unit search path
- a disk version of the unit in yet another directory B where directory B is in the unit search path
- unit A and unit B have different content
This works the same in all versions of Delphi: the unit file referenced in the .dpr is compiled.
Via: [WayBack] Jeroen Pluimers on Twitter: “Delphi 10.2 Tokyo and 10.3 Rio compilers break Delphi 1…10.1 Berlin behaviour. Still reproducing and researching the consequences. It for instance means stuff suddenly compiles when it should not, or breaks when it should not. Preliminary reproduction at “
[WayBack] wiert.me / public / delphi / DelphiConsoleProjectWithMissingProjectUnitThatIsOnTheSearchPath · GitLab
–jeroen








