View Issue Details

IDProjectCategoryView StatusLast Update
0038587PackagesPackagespublic2021-03-07 15:57
ReporterGeorge Assigned ToMattias Gaertner  
Status resolvedResolutionfixed 
OSWindows x64 
Product Version2.1 (SVN) 
Summary0038587: Project package dependencies does not resolves as expected
DescriptionFound strange behaviour, that looks like a bug.

Part 1 - making local dependencies for each project.

We can put our dependencies in project subfolder:

Now if I open mormot_base.lpk from dependencies\mormot\Packages and click "use" - "add to project", package will appear in project inspector as dependency.
lpi file will contain information about new dependency:
    <PackageName Value="mormot_base"/>

I want to make this dependency local to one project.
From project inspector, I perform right click on mormot_base and choose option "store file name as default for this dependency".
Now, lpi file contain proper relative path:

    <PackageName Value="mormot_base"/>
    <DefaultFilename Value="..\dependencies\mormot\Packages\mormot_base.lpk"/>

But for some reason, this path will not be used as default.
despite that project has local lpk that properly listed in lpi file.
This is really looks like a bug.

Part 2 - global dependency store.

I Created global dependencies folder, for multiple versions of each one:
lazarus-packages\mormot\master\ // <- only this one connected to git repo

Opened lpk from each version, ensured that each lpk contain proper version (1.18.6247 and 1.18.6132).
Each time when we open lpk package, lazarus will remember package name + version + path.
So, now I can see both packages from menu - package - package links.

I added dependency to my project from project inspector - right click on dependencies, find mormot_base and specify "minimum" and "maximum" version.
For project 1 I set minimum and maximum version to 1.18.6132.
For project 2 I set minimum and maximum version to 1.18.6247.
Now, each project requests exact mormot_base version and lazarus know where it is (checked menu - packages - package links).

But for some reason, Lazarus can't properly load requested package for second project (project - close project and open another).
I get error: The following package failed to load: mormot_base (>=1.18.6247) (<=1.18.6247).
But if I re-open project again, package will be loaded without error.
TagsNo tags attached.
Fixed in Revision64759.
Attached Files


related to 0029677 assignedMattias Gaertner Lazarus IDE Packager exception during project opening 



2021-03-05 19:08

reporter   ~0129403

Here is screenshot from "Part 2"
part2.png (32,840 bytes)   
part2.png (32,840 bytes)   

Mattias Gaertner

2021-03-05 19:09

manager   ~0129404

About "store as default":
As explained here:
The default is only used, when the IDE does not know any mormot_base.lpk.

How did you test?

Mattias Gaertner

2021-03-05 19:10

manager   ~0129405

Please create one bug report per issue.


2021-03-05 20:15

reporter   ~0129407

Last edited: 2021-03-05 20:24

View 4 revisions

Ok, for part 2 I will open another issue later.
This one will be focused on Part 1.

I prepared video showcase:
(google need some time to process video, check quality switcher as well or just download it)

I don't see the point, why lazarus should not pick up package from specified relative path from lpi file.
This path should be used as maximum priority path, isn't it? Path that specified at project level.
But for some reason, Lazarus just use last opened package instead.
I can re-add dependency to proj1, then, if I open proj2 it will use lpk from package1 as well (will ignore package path from project lpi).

Balázs Székely

2021-03-05 21:25

developer   ~0129409

If I understood you correctly, you wish to use a separate version of mormot for project1 and project2. Unfortunately you cannot have two packages(units) with the same name in the Lazarus "ecosystem". Once you opened the second mormot package the first one is disregarded.


2021-03-05 22:29

reporter   ~0129412

Last edited: 2021-03-05 22:49

View 4 revisions

>> you wish to use a separate version of mormot for project1 and project2

As you mentioned, packages indeed have identical names, but different versions and paths.
Is it compiler limitation? Why we can't use runtime packages with different versions and properly specified path from project lpi?
Seems my second part related with this limitation. Lazarus IDE creates an impression that multiple packages with different versions are supported,
since it correctly show package links, also Lazarus understand that packages have same name, but different version and paths.
Moreover, we can specify dependency version that required by project.

Is there any chance this limitation could be revised and re-investigated?
NPM allows to use local node_modules for each project or global, that's so developer friendly.
With Lazarus, it's seems that packages can't be used at all if developer have few projects with different package version (and can't just sync all dependencies across all projects).

I can understand why design time packages can't be installed on per-project basis.
But runtime, that even don't require installation in IDE, it's all about correct path resolution.

Juha Manninen

2021-03-05 23:10

developer   ~0129414

Yes, the IDE should support packages with the same name but different version and/or path but it does not work now.
I don't know how long it has been broken.
The related report has a similar problem, but his packages don't even have different versions. The IDE has code to handle it but it does not work.
This is quite essential, it should preferably be fixed for 2.2 release.


2021-03-05 23:25

reporter   ~0129415

Last edited: 2021-03-06 09:11

View 2 revisions

I see...
Can we leave this issue opened or even increase Severity or Priority?

Juha Manninen

2021-03-06 10:56

developer   ~0129425

I set Severity=major. I also updated Product Version.
Supporting different versions of a package is important IMO.
I don't dare to set target for 2.2 yet. This may be difficult to fix and should not delay the release which has been delayed already.

Balázs Székely

2021-03-06 11:33

developer   ~0129427

Since Mormot is a "Runtime only" package, all you have to do is to rename one of the lpk files. Just tested, it works fine(see attached screenshot). You wouldn't be able to pull this off with a "Desingtime" package, because you run into the duplicate unit name error(also tested).
Packages.png (60,953 bytes)   
Packages.png (60,953 bytes)   


2021-03-06 12:07

reporter   ~0129428


I will use it as workaround, until Lazarus will be able to handle multiple runtime package versions with same name.

Balázs Székely

2021-03-06 14:35

developer   ~0129431

As a follow up AddPkgDependencyDlg does not allow two packages with the same name in the list:

procedure TAddPkgDependencyDialog.AddUniquePackagesToList(APackageID: TLazPackageID);
  if (APackageID.IDAsString<>fProjPack.IDAsString) and (fPackages.Find(APackageID)=Nil) then

In my opinion the package system was not designed to support multiple version of the same package, or was in the beginning then limited to one unique package for some reason.

Mattias Gaertner

2021-03-06 14:51

manager   ~0129432

It was designed from the beginning to support one package *loaded* per name and multiple versions of one package on disk, using Min/MaxVersions.


2021-03-06 15:30

reporter   ~0129434

Last edited: 2021-03-06 15:32

View 2 revisions

>> It was designed from the beginning to support one package *loaded* per name and multiple versions of one package on disk, using Min/MaxVersions.
Currently min/max on disk does not work as well, exactly what I described in Part 2.
I think, both parts should be one issue and solved together when time comes.

In my opinion, since only one package can be loaded at a time, runtime packages must be loaded after the project is created or opened.
Lazarus should check project dependencies and find proper known packages locations.
If lpi file include relative path to the package (DefaultFilename), this path should be used by default (if path is incorrect or version not math the required version, Lazarus can show package load error (like in screenshot above)).
After project close, Lazarus should unload those runtime packages that was loaded before, in order to prepare for another project with another set of runtime dependencies.

Mattias Gaertner

2021-03-06 17:13

manager   ~0129438

As Juha already wrote: it worked in the past and something broke - it's a regression and needs to be fixed.

Juha Manninen

2021-03-07 14:31

developer   ~0129478

Wow, Mattias fixed it!
It seems a copy / paste error in my code was involved. :(

     // Assign relevant data to temp variables
- MaxVers.Assign(aDep.MinVersion);
+ MaxVers.Assign(aDep.MaxVersion);
     // read minimum version
     if UseMinVersionCheckBox.Checked then begin


2021-03-07 15:49

reporter   ~0129481

Last edited: 2021-03-07 15:51

View 2 revisions

It seems that this should fix issue that I named as "Part2". Am I Right?
Does it fix as well "Part1"? If not, should I create another ticket for Part1? (in other words, is it possible that Part1 will be solved as well?)
Part 1 showcase:

Mattias Gaertner

2021-03-07 15:54

manager   ~0129483

In a simple example here Part 1 works. Please create a separate bug report with more detailed steps to reproduce the problem.


2021-03-07 15:57

reporter   ~0129484

Ok, Thanks!

Issue History

Date Modified Username Field Change
2021-03-05 17:19 George New Issue
2021-03-05 18:37 Juha Manninen Relationship added related to 0029677
2021-03-05 19:08 George Note Added: 0129403
2021-03-05 19:08 George File Added: part2.png
2021-03-05 19:09 Mattias Gaertner Note Added: 0129404
2021-03-05 19:10 Mattias Gaertner Note Added: 0129405
2021-03-05 20:15 George Note Added: 0129407
2021-03-05 20:19 George Note Edited: 0129407 View Revisions
2021-03-05 20:22 George Note Edited: 0129407 View Revisions
2021-03-05 20:24 George Note Edited: 0129407 View Revisions
2021-03-05 21:25 Balázs Székely Note Added: 0129409
2021-03-05 22:29 George Note Added: 0129412
2021-03-05 22:43 George Note Edited: 0129412 View Revisions
2021-03-05 22:48 George Note Edited: 0129412 View Revisions
2021-03-05 22:49 George Note Edited: 0129412 View Revisions
2021-03-05 23:10 Juha Manninen Note Added: 0129414
2021-03-05 23:25 George Note Added: 0129415
2021-03-06 09:11 George Note Edited: 0129415 View Revisions
2021-03-06 10:52 Juha Manninen Severity minor => major
2021-03-06 10:52 Juha Manninen Product Version 2.0.10 => 2.1 (SVN)
2021-03-06 10:52 Juha Manninen LazTarget => -
2021-03-06 10:56 Juha Manninen Note Added: 0129425
2021-03-06 11:33 Balázs Székely Note Added: 0129427
2021-03-06 11:33 Balázs Székely File Added: Packages.png
2021-03-06 12:07 George Note Added: 0129428
2021-03-06 14:35 Balázs Székely Note Added: 0129431
2021-03-06 14:51 Mattias Gaertner Note Added: 0129432
2021-03-06 15:30 George Note Added: 0129434
2021-03-06 15:32 George Note Edited: 0129434 View Revisions
2021-03-06 17:13 Mattias Gaertner Note Added: 0129438
2021-03-06 21:58 Mattias Gaertner Assigned To => Mattias Gaertner
2021-03-06 21:58 Mattias Gaertner Status new => resolved
2021-03-06 21:58 Mattias Gaertner Resolution open => fixed
2021-03-06 21:58 Mattias Gaertner Fixed in Revision => 64759.
2021-03-07 14:31 Juha Manninen Note Added: 0129478
2021-03-07 15:49 George Note Added: 0129481
2021-03-07 15:51 George Note Edited: 0129481 View Revisions
2021-03-07 15:54 Mattias Gaertner Note Added: 0129483
2021-03-07 15:57 George Note Added: 0129484