Thread overview
I really don't understand DUB
Apr 08, 2019
WhatMeWorry
Apr 08, 2019
Dennis
Apr 14, 2019
Ron Tarrant
Apr 14, 2019
Andre Pany
Apr 15, 2019
Russel Winder
Apr 15, 2019
Paolo Invernizzi
Apr 15, 2019
diniz
Apr 15, 2019
Ron Tarrant
April 08, 2019
I've been using DUB for several years and I've gotten it to work generally.  But I've been trying to troubleshoot a DUB issue for two days now and I've come to the conclusion, I don't really understand DUB and I'm tired of muddling through.  (Surely it hurts that I've never been exposed to a library or package manager in general)   Now, I've studied the on-line documentation and even walked through the code somewhat but I'm not making an headway.

Maybe a higher level approach is required. Is there some good beginner tutorial that I'm missing?   Ideally, like a gentle walk through, for both Windows and POSIX?
April 08, 2019
On Monday, 8 April 2019 at 19:54:28 UTC, WhatMeWorry wrote:
> Now, I've studied the on-line documentation and even walked through the code somewhat but I'm not making an headway.

Very relatable. My tips so far are:

- Look for projects in github with a similar structure to yours and look at their package files. Want to split up your library in sub-components? Look at:
https://github.com/d-gamedev-team/gfm/blob/master/dub.json
or:
https://github.com/AuburnSounds/Dplug/blob/master/dub.json

Want to build a game on Windows without console, with and icon and including Dll's?
https://github.com/gecko0307/dagon-demo/blob/master/dub.json

- If you think "okay, my D project is slightly unconventional, but I think I can make it work with dub using the right configuration / preBuildCommands / targetType none": It's an uphill battle, it won't work well (or at all).

- bookmark the package reference (https://dub.pm/package-format-json.html), you'll go back to it a lot.

> (Surely it hurts that I've never been exposed to a library or package manager in general)

It shouldn't be this hard to grasp.

> Is there some good beginner tutorial that I'm missing?

Nope. I considered writing one, but the prerequisite of that is that I understand dub myself. You'll have to do with:

https://dub.pm/getting_started.html
https://dub.pm/advanced_usage.html
https://github.com/dlang/dub/wiki/Cookbook
April 14, 2019
On Monday, 8 April 2019 at 19:54:28 UTC, WhatMeWorry wrote:
> I've been trying to troubleshoot a DUB issue for two days now and I've come to the conclusion, I don't really understand DUB and I'm tired of muddling through.

Just so you know who I am and what my experience is:

I've only been using D for a few months and so far, I've only dabbled in dub. I used to write a blog for PHP-GTK years ago, but now I'm writing one based on GtkD.

I was asked early on why I'm not using dub and the short answer is: I don't understand it (either).

Today I decided I'd get back to my notes on dub (which is leading to a blog post on how to use it) but during a search, I turned up a thread on here talking about how dub needs an overhaul... or at least, a tune-up.

But I carried on anyway and did a few more experiments with dub. However, I ran into a mystery while compiling one of my GtkD test files...

The first time I compiled it (using dub, of course) it compiled without complaint.

Then I decided to see if I could change the name of the central source file from app.d to main.d and added a line to the dub.sdl file like this:

mainSourceFile "main.d"

After attempting to compile and realizing this was wrong, I read the docs on .sdl files and found that all I had to do is change the name of the file. No mention of this change is needed in dub.sdl.

So, I tried that and got the warning:

warning LNK4255: library contain multiple objects of the same name; linking object as if no debug info

So, I changed it all back to the way it was, but still got the warning.

And this warning also comes up whenever I try to compile a single-file dub project (where the sdl args are framed in /+ +/ at the top of file.d).

At that point, with this mystery warning, the talk of dub needing an overhaul, and the number of new-ish D programmers who just don't understand dub, I decided to, once again, put my blog post on dub on the back burner.

All this to say: I feel your pain and hope you can find a way to keep on keeping on, with or without dub.
April 14, 2019
On Sunday, 14 April 2019 at 19:46:41 UTC, Ron Tarrant wrote:
> On Monday, 8 April 2019 at 19:54:28 UTC, WhatMeWorry wrote:
>> [...]
>
> Just so you know who I am and what my experience is:
>
> I've only been using D for a few months and so far, I've only dabbled in dub. I used to write a blog for PHP-GTK years ago, but now I'm writing one based on GtkD.
>
> I was asked early on why I'm not using dub and the short answer is: I don't understand it (either).
>
> Today I decided I'd get back to my notes on dub (which is leading to a blog post on how to use it) but during a search, I turned up a thread on here talking about how dub needs an overhaul... or at least, a tune-up.
>
> But I carried on anyway and did a few more experiments with dub. However, I ran into a mystery while compiling one of my GtkD test files...
>
> The first time I compiled it (using dub, of course) it compiled without complaint.
>
> Then I decided to see if I could change the name of the central source file from app.d to main.d and added a line to the dub.sdl file like this:
>
> mainSourceFile "main.d"
>
> After attempting to compile and realizing this was wrong, I read the docs on .sdl files and found that all I had to do is change the name of the file. No mention of this change is needed in dub.sdl.
>
> So, I tried that and got the warning:
>
> warning LNK4255: library contain multiple objects of the same name; linking object as if no debug info
>
> So, I changed it all back to the way it was, but still got the warning.
>
> And this warning also comes up whenever I try to compile a single-file dub project (where the sdl args are framed in /+ +/ at the top of file.d).
>
> At that point, with this mystery warning, the talk of dub needing an overhaul, and the number of new-ish D programmers who just don't understand dub, I decided to, once again, put my blog post on dub on the back burner.
>
> All this to say: I feel your pain and hope you can find a way to keep on keeping on, with or without dub.

You are totally right, it should be more intuitive how to use dub.

As far as I know if you do not specify in dub.json/dub.sdl what type of package you have (executable/library) dub make a guess. Is there an app.d it will default the targetType "executable", if not it will default the targetType "library".

To solve your specify the targetType explicitly in your dub.sdl file.

https://dub.pm/package-format-json.html#target-types

Kind regards
Andre
April 15, 2019
On Sun, 2019-04-14 at 20:51 +0000, Andre Pany via Digitalmars-d-learn
wrote:
[…]
> As far as I know if you do not specify in dub.json/dub.sdl what type of package you have (executable/library) dub make a guess. Is there an app.d it will default the targetType "executable", if not it will default the targetType "library".
[…]

I had understood that if source/main.d existed the project type would also be executable, the same as if source/app.d existed.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



April 15, 2019
On Sunday, 14 April 2019 at 20:51:10 UTC, Andre Pany wrote:
> On Sunday, 14 April 2019 at 19:46:41 UTC, Ron Tarrant wrote:
>> [...]
>
> You are totally right, it should be more intuitive how to use dub.
>
> As far as I know if you do not specify in dub.json/dub.sdl what type of package you have (executable/library) dub make a guess. Is there an app.d it will default the targetType "executable", if not it will default the targetType "library".
>
> To solve your specify the targetType explicitly in your dub.sdl file.
>
> https://dub.pm/package-format-json.html#target-types
>
> Kind regards
> Andre

The Zen of Python, rule number two: explicit is better than implicit ...

I guess that just killing all that educated dub guess will turn dub into a much easier tool to grasp.

- P
April 15, 2019
Le 15/04/2019 à 09:57, Paolo Invernizzi via Digitalmars-d-learn a écrit :
> I guess that just killing all that educated dub guess will turn dub into a much easier tool to grasp.

Probably. I had similar issues as well. Now I keep all as simple and explicit as possible. (And it works, at least in simple cases like my uses are as of now.)

-- 
diniz {la vita e estranj}
April 15, 2019
On Sunday, 14 April 2019 at 20:51:10 UTC, Andre Pany wrote:

> To solve your specify the targetType explicitly in your dub.sdl file.
>
> https://dub.pm/package-format-json.html#target-types
>
> Kind regards
> Andre

Thanks, Andre. Yeah, I did sort that out. My dilemma ATM is why I'm (seemingly randomly) getting linker warnings.