RejectedSoftware Forums

Sign up

Can't get my new dub library thing to work

Hi guys.
I have been playing around with the D-Language for quite a while now, and have never done anything serious with it. So I've decided to attempt to contribute somewhat by writing and publishing a simple library, that will enable people to pull information from DataDog (which is something I use in work a bit).

However ...
I can't for the life of me, get it to work. I know I'm missing something simple to get the package working, but I don't know what it is.

I have made a dub package datadogd which at the moment is relative simple. However when I include it in a new dub package using:

import std.stdio;
import datadogd ;

void main() {
	writeln("Hello World.");
}

and changing my dub.json to be

{
	"name" : "extraction",
	"description" : "Hello World - A minimal DUB bundle.",
	"dependencies" : {
			"datadogd": "~>0.1.0"
	}
}

I get

brian@tonk:~/workspace/Extraction$ dub
Performing "debug" build using dmd for x86_64.
extraction ~master: building configuration "application"...
src/app.d(3,8): Error: module datadogd is in file 'datadogd.d' which cannot be read
import path[0] = src/
import path[1] = /usr/include/dmd/phobos
import path[2] = /usr/include/dmd/druntime/import
dmd failed with exit code 1.
brian@tonk:~/workspace/Extraction$ 

I've tried extensive googling of the error and also tried some changes to the package versioning, and nameing and anything else I could logically think of, but nothing seems to work.
I've also tried changing the import statement to

import datadogd.source.datadogd

but that gives the same message or some variant.

I know something is wrong with my package that I created in Github, but darned if I can figure it out.

It's the first time I've used github and/or SemVer specification and/or created a dub package in earnest, so I'm not sure which part I'm failing at. :P

Any help would be much appreciated.

Regards
Brian

Re: Can't get my new dub library thing to work

I think you need to change the first line of source/datadogd to:

module datadogd;

and import it using:

import datadogd;

The source directory is the root of the import path, so it shouldn't
appear in the module name.

Re: Can't get my new dub library thing to work

Thanks for replying!I was basically trying all sorts of things to try and force it to "find the unfindable" which I can't figure out.

I changed it to your suggestion below and retried.
Still have the same error. :S

I tried to copy one of the other modules in the dub library, but I can't see where mine is different and hence why it doesn't work.
Hence raising a ticket.

Any other suggestions?

Is there a step-by-step guide to create a "hello world dub library"?
If I could get it to work, I'll gladly write one. :)

On Wed, 7 Oct 2015 19:30:51 +0200, Marc Schütz wrote:

I think you need to change the first line of source/datadogd to:

module datadogd;

and import it using:

import datadogd;

The source directory is the root of the import path, so it shouldn't
appear in the module name.

Re: Can't get my new dub library thing to work

Am 08.10.2015 um 07:24 schrieb infinityplusb:

Thanks for replying!I was basically trying all sorts of things to try and force it to "find the unfindable" which I can't figure out.

I changed it to your suggestion below and retried.
Still have the same error. :S

I tried to copy one of the other modules in the dub library, but I can't see where mine is different and hence why it doesn't work.
Hence raising a ticket.

Any other suggestions?

Is there a step-by-step guide to create a "hello world dub library"?
If I could get it to work, I'll gladly write one. :)

The problem seems to be that the dub.sdl of the datadogd package
specifies targetType "none", which will cause it to not be included in
the build at all. I'd usually recommend to use the generic targetType <br>"library".

BTW, you should ideally also use license "GPL-2.0" instead of "GPL 2".
Currently this information isn't used for anything but displaying it on
the package's overview page, so it doesn't really matter, but later we
might add a feature that automatically warns about license
incompatibilities.

http://code.dlang.org/getting_started contains a very humble attempt
at a step-by-step guide, but could be improved in many ways and doesn't
really mention common pitfalls.

Re: Can't get my new dub library thing to work

The problem seems to be that the dub.sdl of the datadogd package
specifies targetType "none", which will cause it to not be included in
the build at all. I'd usually recommend to use the generic targetType <br>"library".

BTW, you should ideally also use license "GPL-2.0" instead of "GPL 2".
Currently this information isn't used for anything but displaying it on
the package's overview page, so it doesn't really matter, but later we
might add a feature that automatically warns about license
incompatibilities.

http://code.dlang.org/getting_started contains a very humble attempt
at a step-by-step guide, but could be improved in many ways and doesn't
really mention common pitfalls.

I tried that now.
I have now changed dub.sdl to have TargetType "library" but when I use it as part of my project though, it appears to generate a dub.json in the ~/.dub/packages/... folder and not a dub.sdl.
I assume that's correct, but it doesn't appear to be picking up the changes I made to the dub.sdl and updating the dub.json.

However to test that your suggestion was the issue, I then went into the ~/.dub/packages/datadogd-0.1.0/dub.json and manually changed it to have "TargetType": "library" and it seems to work (now it's just my coding that's the problem :P )

I'll revert to using dub.json instead of dub.sdl for the time being, and purge the dub.sdl from my github.

Thanks for the help.

Re: Can't get my new dub library thing to work

On Sun, 11 Oct 2015 01:24:19 GMT, infinityplusb wrote:

The problem seems to be that the dub.sdl of the datadogd package
specifies targetType "none", which will cause it to not be included in
the build at all. I'd usually recommend to use the generic targetType <br>"library".

(...)

I tried that now.
I have now changed dub.sdl to have TargetType "library" but when I use it as part of my project though, it appears to generate a dub.json in the ~/.dub/packages/... folder and not a dub.sdl.
I assume that's correct, but it doesn't appear to be picking up the changes I made to the dub.sdl and updating the dub.json.

However to test that your suggestion was the issue, I then went into the ~/.dub/packages/datadogd-0.1.0/dub.json and manually changed it to have "TargetType": "library" and it seems to work (now it's just my coding that's the problem :P )

I'll revert to using dub.json instead of dub.sdl for the time being, and purge the dub.sdl from my github.

Thanks for the help.

The problem is probably not dub.sdl vs. dub.json (DUB always creates a dub.json file when downloading packages, because it needs to add a "version" field and currently can only write in JSON format). Did you create a new version tag after making the change in dub.sdl? If not, it probably just picked up the old version.

When trying out such things, you can also use dub add-local /path/to/package or dub add-path /path/to/ to make your local working copy available. DUB will then use the local version as long as the latest tag matches the version that is requested by the dependent project.