Thread overview
How to build a specific library version with dub?
Apr 11, 2021
martinm
Apr 11, 2021
martinm
Apr 11, 2021
Mike Parker
Apr 15, 2021
martinm
April 11, 2021

I'm trying to use wayland-d which depends on derelict-util-2.0.6.
DUB can't download the zip and fails.
I download the zip to ~/.dub/packages/derelict-util folder, unzip and build.
DUB builds DerelictUtil.a ~master.

Trying to rebuild wayland-d, DUB can't find derelict-util-2.0.6 dependency.
dub list | grep -i derelict shows:
derelict-util ~master ~/.dub/packages/derelict-util-2.0.6/derelict-util/
is there.

How can DUB build 2.0.6 version ?
dub build library@2.0.6 fails
(1) : Error: Got JSON of type null_, expected object.

How can I change registry and manually change ~master to 2.0.6 ?

Why is DUB stupid program ?

April 11, 2021

On Sunday, 11 April 2021 at 13:43:47 UTC, martinm wrote:

>

I'm trying to use wayland-d which depends on derelict-util-2.0.6.
DUB can't download the zip and fails.
I download the zip to ~/.dub/packages/derelict-util folder, unzip and build.
DUB builds DerelictUtil.a ~master.

Trying to rebuild wayland-d, DUB can't find derelict-util-2.0.6 dependency.
dub list | grep -i derelict shows:
derelict-util ~master ~/.dub/packages/derelict-util-2.0.6/derelict-util/
is there.

How can DUB build 2.0.6 version ?
dub build library@2.0.6 fails
(1) : Error: Got JSON of type null_, expected object.

How can I change registry and manually change ~master to 2.0.6 ?

Why is DUB stupid program ?

Solution:

I open dub.json in ~/.dub/packages/derelict-util and add line:
"version": "2.0.6"

now DUB list shows
derelict-util 2.0.6 ...

and building wayland-d is ok.

April 11, 2021

On Sunday, 11 April 2021 at 13:43:47 UTC, martinm wrote:

>

I'm trying to use wayland-d which depends on derelict-util-2.0.6.
DUB can't download the zip and fails.
I download the zip to ~/.dub/packages/derelict-util folder, unzip and build.
DUB builds DerelictUtil.a ~master.

That's not how to go about this. You should never need to manually install a library for dub to use it.

Assuming you mean this library:

https://github.com/rtbo/wayland-d

It's the DerelictUtil dependency is configured as ~>2.0.3. This syntax means >= 2.0.3 and < 2.1.0. So when you build the wayland package for the first time, dub should pick up the latest version in the 2.0.x series without any special help from you.

>

Trying to rebuild wayland-d, DUB can't find derelict-util-2.0.6 dependency.
dub list | grep -i derelict shows:
derelict-util ~master ~/.dub/packages/derelict-util-2.0.6/derelict-util/
is there.

Dub is picking up ~master in this case because you manually copied DerelictUtil into the .dub directory from the zip file. Dub has absolutely no way to know what version of the library that is un less you tell it (see below).

>

How can DUB build 2.0.6 version ?
dub build library@2.0.6 fails
(1) : Error: Got JSON of type null_, expected object.

Have you modified DerelictUtil's dub.json in any way? I just ran dub build on the 2.0 branch of DerelictUtil and built 2.0.6 without error.

>

How can I change registry and manually change ~master to 2.0.6 ?

IMO, the best thing to do is to delete the DerelictUtil folder you unzipped and let dub pull down DerelictUtil automatically, then it will know it has 2.0.6.

However, whenever you want to manually install a package, you don't have to put the source files in the .dub directory. You can put them anywhere on your system, then use the dub command line to add that folder to your local registry and specify the version. Something like: dub add-local . --version=2.0.6.

You could also just run dub fetch derelict-util --version=2.0.6.

April 15, 2021

On Sunday, 11 April 2021 at 15:01:04 UTC, Mike Parker wrote:

>

On Sunday, 11 April 2021 at 13:43:47 UTC, martinm wrote:

>

I'm trying to use wayland-d which depends on derelict-util-2.0.6.
DUB can't download the zip and fails.
I download the zip to ~/.dub/packages/derelict-util folder, unzip and build.
DUB builds DerelictUtil.a ~master.

That's not how to go about this. You should never need to manually install a library for dub to use it.

I think so, too but when it's not working what can I do.
I wrote 2. sentence DUB fails can't download, timeout and fails.

>

Assuming you mean this library:

https://github.com/rtbo/wayland-d

Yes that one.

>

It's the DerelictUtil dependency is configured as ~>2.0.3. This syntax means >= 2.0.3 and < 2.1.0. So when you build the wayland package for the first time, dub should pick up the latest version in the 2.0.x series without any special help from you.

Like said before. DUB download does not work.

> >

Trying to rebuild wayland-d, DUB can't find derelict-util-2.0.6 dependency.
dub list | grep -i derelict shows:
derelict-util ~master ~/.dub/packages/derelict-util-2.0.6/derelict-util/
is there.

Dub is picking up ~master in this case because you manually copied DerelictUtil into the .dub directory from the zip file. Dub has absolutely no way to know what version of the library that is un less you tell it (see below).

Yes, I download DerelictUtil v. 2.0.6 release from github, unzip in .dub/packages and build myself.

> >

How can DUB build 2.0.6 version ?
dub build library@2.0.6 fails
(1) : Error: Got JSON of type null_, expected object.

Have you modified DerelictUtil's dub.json in any way? I just ran dub build on the 2.0 branch of DerelictUtil and built 2.0.6 without error.

Yes, I added "version": "2.0.6" to dub.json and 2.0.6 is now correctly in registry.

> >

How can I change registry and manually change ~master to 2.0.6 ?

IMO, the best thing to do is to delete the DerelictUtil folder you unzipped and let dub pull down DerelictUtil automatically, then it will know it has 2.0.6.

DUB still fails to download file itself. Maybe DUB should try GITHUB like I did.

>

However, whenever you want to manually install a package, you don't have to put the source files in the .dub directory. You can put them anywhere on your system, then use the dub command line to add that folder to your local registry and specify the version. Something like: dub add-local . --version=2.0.6.
You could also just run dub fetch derelict-util --version=2.0.6.

This is good advice. Thank you.

I know my way is bad but it works for me and I prefer Makefile than DUB. Makefile can be complex but if problem I search in internet and 5 or 10 minutes later problem is solved. DUB is good when works but when not I see ??? I search in internet and find nothing and need come to forum and after 1h, problem can be fixed or not.

But thank you for explanation.