RejectedSoftware Forums

Sign up

Library as dependency and using the correct import path.

Hi all,

After a long hiatus, I've decidede to pick up programming in D again and found out about Dub while researching how to use Ncurses. For this I made a sample hello world-app with dub init and listed ncurses-d (from the registry) as the dependency. Because of the lack of documentation, however, I'm not sure if what I'm doing is the right thing.
I do the following steps before ~/.dub is even created, and while I managed to get it to work, I thought Dub was supposed to find the correct paths for where Ncurses is installed.
My dub.json looks like:

{
    "name": "game",
    "description": "A game in D",
    "copyright": "Copyright © 2014, Neal van Veen",
    "authors": ["Neal van Veen"],
    "license": "GPL-3.0",
    "dependencies": {
      "ncurses": "~master",
    },
    "sourcePaths": [
      "src"
    ],
    "importPaths": [
      "lib/ncurses-master"
    ],
}

My problem is that I have ncurses locally fetch'd in lib/ncurses-master, while I was under the impression that I don't even need to do that as it's an external dependency that dub automatically fetches and puts in ~/.dub. If I do it that way (having ncurses in ~/.dub and losing the importPaths directive), dmd complains that it can't find the deimos.ncurses (from import deimos.ncurses; statement).
What am I doing wrong that dub run will fetch ncurses but won't add its dub directory path automatically to the package? I would have thought that it isn't necessary that I keep a local copy of the ncurses lib.

I hope someone can explain this to me, or otherwise tell me I don't understand the proper purpose for dub.

Thanks in advance,

Neal.

Re: Library as dependency and using the correct import path.

On Mon, 10 Mar 2014 13:34:42 GMT, Neal van Veen wrote:

Hi all,

After a long hiatus, I've decidede to pick up programming in D again and found out about Dub while researching how to use Ncurses. For this I made a sample hello world-app with dub init and listed ncurses-d (from the registry) as the dependency. Because of the lack of documentation, however, I'm not sure if what I'm doing is the right thing.
I do the following steps before ~/.dub is even created, and while I managed to get it to work, I thought Dub was supposed to find the correct paths for where Ncurses is installed.
My dub.json looks like:

{
    "name": "game",
    "description": "A game in D",
    "copyright": "Copyright © 2014, Neal van Veen",
    "authors": ["Neal van Veen"],
    "license": "GPL-3.0",
    "dependencies": {
      "ncurses": "~master",
    },
    "sourcePaths": [
      "src"
    ],
    "importPaths": [
      "lib/ncurses-master"
    ],
}

My problem is that I have ncurses locally fetch'd in lib/ncurses-master, while I was under the impression that I don't even need to do that as it's an external dependency that dub automatically fetches and puts in ~/.dub. If I do it that way (having ncurses in ~/.dub and losing the importPaths directive), dmd complains that it can't find the deimos.ncurses (from import deimos.ncurses; statement).
What am I doing wrong that dub run will fetch ncurses but won't add its dub directory path automatically to the package? I would have thought that it isn't necessary that I keep a local copy of the ncurses lib.

I hope someone can explain this to me, or otherwise tell me I don't understand the proper purpose for dub.

Thanks in advance,

Neal.

Your assumptions are completely correct, but there seems to be an error in the package description of the ncurses package - it's missing the proper "importPaths" field. I'll open a pull request to fix it.

Re: Library as dependency and using the correct import path.

Pull request: #20