How to build a specific library version with dub?
Mike Parker
aldacron at gmail.com
Sun Apr 11 15:01:04 UTC 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 at 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`.
More information about the Digitalmars-d-learn
mailing list