Dub project has both .sdl and .json files. Is this normal or did I do something wrong?
WebFreak001
d.forum at webfreak.org
Mon Dec 18 22:57:36 UTC 2017
On Monday, 18 December 2017 at 22:36:44 UTC, WhatMeWorry wrote:
>
> I've been using Dub for a while but from the very beginning I
> decided to go with SDL 100% of the time, So I've got a dub.sdl
> file like:
>
> name "01_10_camera_view_space"
> description "A minimal D application."
> authors "kheaser"
> copyright "Copyright © 2017, kheaser"
> license "proprietary"
>
> dependency "derelict-al" version="~>1.0.3"
> dependency "derelict-assimp3" version="~>1.3.0"
> dependency "derelict-fi" version="~>2.0.3"
> dependency "derelict-fmod" version="~>2.0.4"
> dependency "derelict-ft" version="~>1.1.3"
> dependency "derelict-gl3" version="~>1.0.23"
> dependency "derelict-glfw3" version="~>3.1.3"
> dependency "derelict-util" version="~>2.0.6"
> dependency "gl3n" version="~>1.3.1"
> .............
>
>
> But when I look the directory that has the dub.sdl file, I also
> see a file called dub.selections.json
>
> {
> "fileVersion": 1,
> "versions": {
> "derelict-al": "1.0.3",
> "derelict-assimp3": "1.3.0",
> "derelict-fi": "2.0.3",
> "derelict-fmod": "2.0.4",
> "derelict-ft": "1.1.3",
> "derelict-gl3": "1.0.23",
> "derelict-glfw3": "3.1.3",
> "derelict-util": "2.0.6",
> "gl3n": "1.3.1"
> }
> }
>
>
> So how did this .json file get created and can I just delete
> it? I only noticed this because when I was troubleshooting the
> project, I changed the dub.sdl library versions but the
> compile/run was using the library versions in
> dub.selections.json.
>
> I did switch from using DMD to LDC, if that has any bearing.
dub.selections.json is basically broken design, once it's there
it will ignore any version value you write in dub.json/dub.sdl
until you dub upgrade. This can lead to many bugs very easily,
but just remember to dub upgrade every time you change versions
and it will be fine.
dub.selections.json stores the versions which got picked when
first adding the dependency so that others can get the same
version of the dependency and should hopefully get a working
build if you managed to build it. The two major problems: if your
new version range doesn't actually allow that version anymore dub
will still use it anyway until you dub upgrade. Second it doesn't
even store commit hashes when using ~master. So basically
assuming the dependency author properly uses SemVer (don't break
backwards compatibility on minor releases) and your version range
only accepts minor updates it is literally nonsense to freeze the
package on a minor version if your range allows a higher version.
Basically you are missing security patches if you use
dub.selections.json
To be honest I wouldn't push it to git, it keeps changing, always
only gives conflicts and breaks things, especially when using
"path". But the dub devs say it should be pushed, though I have
never seen anything good come out of it.
More information about the Digitalmars-d-learn
mailing list