Examples of dub use needed

Mike Parker via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 21 00:44:14 PDT 2016


On Tuesday, 21 June 2016 at 07:24:33 UTC, poliklosio wrote:

>
> Wow, really?
> Then what is the fetch command for? I started using dub a 
> recently (2 months ago) and totally didn't notice that there is 
> any other purpose of the fetch command. I even installed dcd, 
> dfmt and dscanner through dub fetch, only to find out these 
> were older versions which didn't work.
> So what is the purpose of dub fetch?

One use case is to bypass dub's global package cache for specific 
projects. For example, say you're making something using 
DerelictGL3 and DerelictGLFW3, you could do this:

mkdir derelict
cd derelict
dub fetch --cache=local derelict-glfw3 --version=2.0.0
dub fetch --cache=local derelict-gl3 --version=1.0.18
dub fetch --cache=local derelict-util --version=2.0.4

If you need the libraries for a project that isn't using DUB, you 
can then do this:

dub add-local derelict-util-2.0.4
cd derelict-glfw3-2.0.0
dub build -brelease
cd ../derelict-gl3-1.0.18
dub build -brelease
cd ../derelict-util-2.0.4
dub build -brelease

The first line allows derelict-glfw3 and derelict-gl3 to find 
derelict-util when you are building them.

You can use all of the packages with other dub managed projects 
by just using add-local on each of them and not bothering with 
building any of them.

dub add-local derelict-util-2.0.4
dub add-local derelict-glfw3-2.0.0
dub add-local derelict-gl3-1.0.18

DUB will prefer these over the global cache if they are already 
there. This is useful for making changes to the libraries 
yourself and having them show up in other projects that depend on 
them. You certainly don't want to modify the files in the global 
cache. And if you checkout from git directly, you'd have to 
modify the DUB configuration of any projects you want to make use 
of your changes so that they use paths for their dependencies 
rather than versions. dub fetch + dub add-local is so much 
simpler. A


More information about the Digitalmars-d mailing list