Examples of dub use needed

Mike Parker via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 21 18:56:34 PDT 2016


On Tuesday, 21 June 2016 at 15:02:01 UTC, Guido wrote:

>
> I'm the sort of person who learns by example, and what I was 
> saying is that there aren't enough examples online of how dub 
> is used in a practical setting.

There aren't that many commands for DUB on the command line. Most 
of what you need can be gleaned from dub --help, but there is 
also documentation online [1]. For package configurations, the 
documentation at code.dlang.org covers everything [2] & [3], just 
not always clearly. It's easy enough to get examples for that 
from all of the projects listed in the registry [4]. Just click 
through them to their github or bitbucket repositories and study 
their dub.json/sdl files. And there's always the DUB forums [5.

>
> I'm also the sort of person who doesn't trust toolchains that 
> need to download things every time from the internet just to 
> compile. Is this what dub is doing? In other words, when a 
> project is built using dub, does it use the local cache from 
> the last build by default, check for later versions, pull 
> things from the internet, etc? Or do I need -cache=local for 
> that?

DUB only downloads a package when it first needs it. It will only 
update to a newer version for a given project if you run 'dub 
upgrade' on that project. Given a project foo which relies on DUB 
package libbar 1.0.0:

cd foo
dub build <-- checks if libbar 1.0.0 is in the cache, finds it 
missing, downloads it
dub build <-- checks if libbar 1.0.0 is in the cache, finds it
dub upgrade <-- checks if the latest version is in the cache. If 
not, downloads it
                 according to how you have specified your 
dependency (see [6])


[1] 
https://forum.rejectedsoftware.com/groups/rejectedsoftware.dub/
[2] https://code.dlang.org/package-format?lang=json
[3] https://code.dlang.org/package-format?lang=sdl
[4] https://code.dlang.org/
[5] http://forum.rejectedsoftware.com/groups/rejectedsoftware.dub/
[6] https://github.com/dlang/dub/wiki/Version-management



More information about the Digitalmars-d mailing list