Delphi Continuous Integration: When you get E2202 “Required package ‘rtl’ not found” or F1027 “Unit not found: ‘System.pas'”
Posted by jpluimers on 2016/11/08
If when setting up Continuous Integration (CI) with Delphi and you get errors like E2202
"Required package 'rtl' not found" or F1027
"Unit not found: 'System.pas'", then something is wrong with your library path on the CI server.
Before going into the details of why, the quick solution is to set either of these environment variables in your build script
- Delphi 2007, 2010:
- Delphi XE and up:
Now back to the details of why these might not be set, most information is from my Delphi build automation workshop.
Delphi uses msbuild for building and uses a set of targets files that gather information about the projects and environment. Over time the targets files for Delphi historically are named
CodeGear.*.Targets and perform the Delphi (and C++ Builder) specific parts of the build process and information collecting.
The Library Path is a user setting that – besides being stored in the user registry – is also stored in EnvOptions.proj file saved by the IDE on exiting and loaded by theCodeGear.*.Targets. Circumstances under which the EnvOptions.dproj cannot be found are centered around the user under which the build automation where:
- it has never started the IDE
- it cannot start the IDE
The second can occur for instance when the user has no interactive login privileges which – for server installations – is fairly common.
The first makes you think it is wise to use a build user that can login. But it also means that if you use a regular user for it, he or she can ruin the build process by starting Delphi, modifying the Library Path and exiting Delphi.
So it is a much better idea to either:
- Specify the Library Path in your build process (depending on the Delphi version, set the
- Use Delphi XE2 or up: these version can do without these variables (and generates a reasonable default in the CodeGear.*.Targets)
- delphi – “Required package rtl not found” when building with Hudson – Stack Overflow
- Need some help getting a Delphi XE project compiled (XE2 and XE3 with similar…
- How does MSBuild find the Delphi search path? – Stack Overflow
- Delphi can’t find System.dcu; what should the default path settings be? – Stack Overflow
- DelphiLibraryPath in *.Targets