How to make dub recursively build subPackages?

Steven Schveighoffer schveiguy at
Wed Feb 2 14:07:08 UTC 2022

On 2/2/22 5:14 AM, Vijay Nayar wrote:
> Greetings folks,
> In my project, I have a parent package with several sub-packages, each 
> of which builds into either a library or an executable.
> I first started observing odd problems when I was running `dub build`, 
> it would complain about different versions of vibe-d present, and it 
> suggested running `dub upgrade`. After doing this, I noticed that most 
> subPackages were not actually being upgraded.
> The only thing I have found thus far is to manually run each subPackage 
> one at a time, e.g. `dub :proto; dub :common; ...`.
> Is it possible to get `dub upgrade` to recursively work on all 
> sub-packages?
> My parent package dub.sdl file:
> ```
> name "funnel"
> description "An in-memory queryable database for processing extreme 
> loads of current data."
> authors "Vijay Nayar"
> copyright "Copyright © 2019, Vijay Nayar"
> license "proprietary"
> targetType "none"
> targetPath "target"
> dependency "funnel:proto" version=">=0.0.0"
> dependency "funnel:spout" version=">=0.0.0"
> dependency "funnel:stem" version=">=0.0.0"
> dependency "funnel:mouth" version=">=0.0.0"
> dependency "funnel:common" version=">=0.0.0"
> subPackage "./common"
> subPackage "./proto"
> subPackage "./mouth"
> subPackage "./stem"
> subPackage "./spout"
> ```
> Each subPackage is structured in the same way, for example, the common 
> subPackage:
> ```
> authors "Vijay Nayar"
> copyright "Copyright © 2019, Vijay Nayar"
> description "Common logic between the mouth and spout components."
> license "proprietary"
> name "common"
> targetType "library"
> targetPath "target"
> dependency "funnel:proto" version="*"
> dependency "poodinis" version="~>8.0.3"
> dependency "vibe-d" version="~>0.9.4"
> ```
> I mostly followed the dub documentation in setting up my project. 

If you have them in the same repository, my recommendation is to use 
path dependencies instead of versions.

So, e.g.:

dependency "funnel:proto" path="./proto" // in main dub.sdl
dependency "funnel:proto" path="../proto" // in sibling package

Because otherwise, dub is going to try and fetch the appropriate version 
from an online repository and not use your local files.

Honestly, for packages in the same repository, I'm not sure why you 
would version them separately from the main package. I don't even know 
if that works.


More information about the Digitalmars-d-learn mailing list