RejectedSoftware Forums

Sign up

Module cannot be reached when adding ddb package

Hello,

I am trying out vibe.d (and D and DUB) and have successfully started vibe.d using DUB.

I then attempted to add the PostgreSQL ddb package, by changing my dub.json file to:

{
	"name": "foo",
	"description": "A simple vibe.d server application.",
	"copyright": "Copyright © 2014, scmjpg",
	"authors": ["scmjpg"],
	"dependencies": {
		"vibe-d": "~master",
		"ddb": "~master"
	},
	"versions": ["VibeDefaultMain", "Have_vibe_d"]
}

and added import postgres.db; to my app.d file. Note, this module is in a file named postgres.d that starts with the line module postgres.db;.

However, running DUB results in the error module db is in file 'postgres/db.d' which cannot be read:

Building ddb configuration "library", build type debug.
Ignoring all import libraries for static library build.
Trying to use pkg-config to resolve library flags for [].
pkg-config failed: pkg-config exited with error code 1
Falling back to direct -lxyz flags.
Running dmd...
dmd -lib -of../../../../home/scmjpg/.dub/packages/ddb-master/.dub/build/library-debug-linux.posix-x86_64-dmd-82098C9A9DEEEB56BD28728737878955/libddb.a -debug -g -w -version=VibeLibeventDriver -version=VibeDefaultMain -version=Have_vibe_d -version=Have_ddb -version=Have_libevent -version=Have_openssl -I../../../../home/scmjpg/.dub/packages/ddb-master/source -I../../../../home/scmjpg/.dub/packages/vibe-d-master/source -I../../../../home/scmjpg/.dub/packages/libevent-master -I../../../../home/scmjpg/.dub/packages/openssl-master ../../../../home/scmjpg/.dub/packages/ddb-master/source/ddb/db.d ../../../../home/scmjpg/.dub/packages/ddb-master/source/postgres.d
Copying target from /home/scmjpg/.dub/packages/ddb-master/.dub/build/library-debug-linux.posix-x86_64-dmd-82098C9A9DEEEB56BD28728737878955/libddb.a to  
Building foo configuration "application", build type debug.
Trying to use pkg-config to resolve library flags for ["event", "event_pthreads", "ssl", "crypto"].
Compiling...
dmd -c -of.dub/build/application-debug-linux.posix-x86_64-dmd-CCED7B49303458DB3CB3B179A9415335/foo.o -debug -g -w -version=VibeDefaultMain -version=Have_vibe_d -version=VibeLibeventDriver -version=Have_foo -version=Have_libevent -version=Have_openssl -version=Have_ddb -Isource -I../../../../home/scmjpg/.dub/packages/vibe-d-master/source -I../../../../home/scmjpg/.dub/packages/libevent-master -I../../../../home/scmjpg/.dub/packages/openssl-master -I../../../../home/scmjpg/.dub/packages/ddb-master/source -Jviews source/app.d ../../../../home/scmjpg/.dub/packages/vibe-d-master/source/vibe/appmain.d
source/app.d(2): Error: module db is in file 'postgres/db.d' which cannot be read
import path[0] = source
import path[1] = ../../../../home/scmjpg/.dub/packages/vibe-d-master/source
import path[2] = ../../../../home/scmjpg/.dub/packages/libevent-master
import path[3] = ../../../../home/scmjpg/.dub/packages/openssl-master
import path[4] = ../../../../home/scmjpg/.dub/packages/ddb-master/source
import path[5] = /usr/include/dmd/phobos
import path[6] = /usr/include/dmd/druntime/import
FAIL .dub/build/application-debug-linux.posix-x86_64-dmd-CCED7B49303458DB3CB3B179A9415335 foo executable
Error executing command run: DMD compile run failed with exit code 1

I managed to get the server to build, by running the command with the two ddb source files included:

dmd -c -of.dub/build/application-debug-linux.posix-x86_64-dmd-CCED7B49303458DB3CB3B179A9415335/foo.o -debug -g -w -version=VibeDefaultMain -version=Have_vibe_d -version=VibeLibeventDriver -version=Have_foo -version=Have_libevent -version=Have_openssl -version=Have_ddb -Isource -I../../../../home/scmjpg/.dub/packages/vibe-d-master/source -I../../../../home/scmjpg/.dub/packages/libevent-master -I../../../../home/scmjpg/.dub/packages/openssl-master -I../../../../home/scmjpg/.dub/packages/ddb-master/source -Jviews ../../../../home/scmjpg/.dub/packages/ddb-master/source/postgres.d ../../../../home/scmjpg/.dub/packages/ddb-master/source/ddb/db.d source/app.d ../../../../home/scmjpg/.dub/packages/vibe-d-master/source/vibe/appmain.d

dmd -of.dub/build/application-debug-linux.posix-x86_64-dmd-DCE7870B76F46CAB0B4C3791E9C8E480/test .dub/build/application-debug-linux.posix-x86_64-dmd-DCE7870B76F46CAB0B4C3791E9C8E480/test.o ../../../../home/scmjpg/.dub/packages/ddb-master/libddb.a ../../../../home/scmjpg/.dub/packages/vibe-d-master/libvibe-d.a -L--no-as-needed -L-levent_pthreads -L-levent -L-lssl -L-lcrypto -g

But I'm sure I must be missing something. For vibe.d, the module names match the file names exactly. For ddb, the module names do not match, and seem to require manual intervention. Should this work, and do I need to add something to get it work?

Thanks,
Jon.

Re: Module cannot be reached when adding ddb package

Not a great solution, but I got it to work by adding the ddb source files to my project's dub.json file.

{
    "name": "foo",
    "description": "A simple vibe.d server application.",
    "copyright": "Copyright © 2014, scmjpg",
    "authors": ["scmjpg"],
    "dependencies": {
        "vibe-d": "~master",
        "ddb": "~master"
    },
    "versions": ["VibeDefaultMain", "Have_vibe_d"],
    "sourceFiles": [
        "/home/scmjpg/.dub/packages/ddb-master/source/postgres.d",
        "/home/scmjpg/.dub/packages/ddb-master/source/ddb/db.d",
    ]
}

I guess the real solution is to convince the ddb developers to match the module and the directory structures.

Re: Module cannot be reached when adding ddb package

On Wed, 09 Apr 2014 20:17:16 GMT, Jon Giddy wrote:

Not a great solution, but I got it to work by adding the ddb source files to my project's dub.json file.

{
    "name": "foo",
    "description": "A simple vibe.d server application.",
    "copyright": "Copyright © 2014, scmjpg",
    "authors": ["scmjpg"],
    "dependencies": {
        "vibe-d": "~master",
        "ddb": "~master"
    },
    "versions": ["VibeDefaultMain", "Have_vibe_d"],
    "sourceFiles": [
        "/home/scmjpg/.dub/packages/ddb-master/source/postgres.d",
        "/home/scmjpg/.dub/packages/ddb-master/source/ddb/db.d",
    ]
}

I guess the real solution is to convince the ddb developers to match the module and the directory structures.

Exactly, I guess they didn't notice the mismatch because they were using an old DUB version, which compiled everything at once. A similar workaround would be to use dub build --combined, but the only real solution is to match up the directory structure.