digitalmars.D - dub subpckages and how to depend on them internally
- aliak (69/69) May 29 2018 Hi, I'm trying to get dub working with subpackages and I just
- Martin Tschierschke (13/30) May 31 2018 I had a similar struggle, may be the version is the missing hint:
- aliak (3/15) May 31 2018 Unfortunately that did not work :(
- Jesse Phillips (3/6) May 31 2018 Move your sub packages out of source. And each package will have
- aliak (7/13) May 31 2018 Do you mean dub can't have source folder as a top level source
- drug (2/20) May 31 2018 Yes
- Jesse Phillips (6/20) May 31 2018 Do that.
- aliak (15/24) Jun 03 2018 Ok I tried this as well, but I still get a
- Jesse Phillips (7/15) Jun 03 2018 This is a very complicated answer, so I made a pull request
- aliak (5/24) Jun 03 2018 Ahhh, I see where I went wrong now. Thanks a lot for the help!
Hi, I'm trying to get dub working with subpackages and I just can't quite seem to hit the nail on the head. Any help would be greatly appreciated. This is the current setup is like this, and there's a shared source folder as well called "common" and "sub2" depends on "sub1". lib |-- dub.json |-- source/ | -- sub1/ | -- package.d | -- dub.json | -- sub2/ | -- package.d | -- dub.json | -- common/ lib/dub.json { "targetPath": "bin", "targetType": "library", "dependencies": { "lib:sub1": "*", "lib:sub2": "*", }, "subPackages": [ "./source/sub1", "./source/sub2" ] } And then sub1/dub.json and sub2/dub.json: sub1: { "name": "sub1", "targetType": "library", "sourcePaths": ["./", "../common"], "importPaths": ["./"], "targetPath": "../bin" } sub2: { "name": "sub2", "targetType": "library", "dependencies": { "lib:sub1": "*" }, "sourcePaths": ["./", "../common", "../sub1"], "importPaths": ["./"], "targetPath": "../bin" } So with the current set up, running dub test lib:sub1 works and dub test lib:sub2 works. What doesn't work is if I try "import lib.sub1" from a test project. So in test project dub.json I have: "dependencies": { "lib": { "path": "../../lib" } } I get error: source/app.d(2,8): Error: module `sub1` is in file 'lib/sub1.d' which cannot be read. The output from dub shows one of my import paths is: import path[6] = ../../lib/source/sub1/. But I guess I'm missing something, or doing something wrong. I also tried: "dependencies": { "lib:sub1": { "path": "../../lib" } } But that gives me the same problem. Halp!
May 29 2018
On Tuesday, 29 May 2018 at 23:41:59 UTC, aliak wrote:Hi, I'm trying to get dub working with subpackages and I just can't quite seem to hit the nail on the head. Any help would be greatly appreciated. This is the current setup is like this, and there's a shared source folder as well called "common" and "sub2" depends on "sub1". lib |-- dub.json |-- source/ | -- sub1/ | -- package.d | -- dub.json | -- sub2/ | -- package.d | -- dub.json | -- common/[...]Halp!I had a similar struggle, may be the version is the missing hint: "dependencies": { "diet-ng": "~>1.4", ...., mylib":{ "versions": "~master", "path": "/home/mt/d/mylib" }, .... } Try to place "versions": "~master", beside your path.
May 31 2018
On Thursday, 31 May 2018 at 12:55:10 UTC, Martin Tschierschke wrote:I had a similar struggle, may be the version is the missing hint: "dependencies": { "diet-ng": "~>1.4", ...., mylib":{ "versions": "~master", "path": "/home/mt/d/mylib" }, .... } Try to place "versions": "~master", beside your path.Unfortunately that did not work :(
May 31 2018
On Tuesday, 29 May 2018 at 23:41:59 UTC, aliak wrote:Hi, I'm trying to get dub working with subpackages and I just can't quite seem to hit the nail on the head. Any help would be greatly appreciated.Move your sub packages out of source. And each package will have it's own src folder, which you may have.
May 31 2018
On Thursday, 31 May 2018 at 13:54:07 UTC, Jesse Phillips wrote:On Tuesday, 29 May 2018 at 23:41:59 UTC, aliak wrote:Do you mean dub can't have source folder as a top level source directory if you use subpackages? So do I have to do this? root |-- sub1/source |-- sub2/sourceHi, I'm trying to get dub working with subpackages and I just can't quite seem to hit the nail on the head. Any help would be greatly appreciated.Move your sub packages out of source. And each package will have it's own src folder, which you may have.
May 31 2018
On 31.05.2018 20:56, aliak wrote:On Thursday, 31 May 2018 at 13:54:07 UTC, Jesse Phillips wrote:YesOn Tuesday, 29 May 2018 at 23:41:59 UTC, aliak wrote:Do you mean dub can't have source folder as a top level source directory if you use subpackages? So do I have to do this? root |-- sub1/source |-- sub2/sourceHi, I'm trying to get dub working with subpackages and I just can't quite seem to hit the nail on the head. Any help would be greatly appreciated.Move your sub packages out of source. And each package will have it's own src folder, which you may have.
May 31 2018
On Thursday, 31 May 2018 at 17:56:57 UTC, aliak wrote:On Thursday, 31 May 2018 at 13:54:07 UTC, Jesse Phillips wrote:Do that. You can have a top level source folder, but this is going to be code separate from your subpackage. The subpackage can depend on this top-level project, or the top-level project can depend on the subpackage.On Tuesday, 29 May 2018 at 23:41:59 UTC, aliak wrote:Do you mean dub can't have source folder as a top level source directory if you use subpackages? So do I have to do this? root |-- sub1/source |-- sub2/sourceHi, I'm trying to get dub working with subpackages and I just can't quite seem to hit the nail on the head. Any help would be greatly appreciated.Move your sub packages out of source. And each package will have it's own src folder, which you may have.
May 31 2018
On Thursday, 31 May 2018 at 20:01:43 UTC, Jesse Phillips wrote:On Thursday, 31 May 2018 at 17:56:57 UTC, aliak wrote:Ok I tried this as well, but I still get a module `sub1` is in file 'lib/sub1.d' which cannot be read I put up a GH test project with exactly what I'm doing. https://github.com/aliak00/dub-subpackages. There's a "lib" project that has subpackages "liba" and "libb" and there's a test application that tries to use the subpackages in different ways. The exact error for that setup is: source/app.d(4,9): Error: module `liba` is in file 'lib/liba.d' which cannot be read import path[0] = source/ import path[1] = ../lib/liba/source/ import path[2] = ../lib/libb/source/ import path[3] = /usr/local/opt/dmd/include/dlang/dmd Am I missing sourcePaths or something somewhere?root |-- sub1/source |-- sub2/sourceDo that. You can have a top level source folder, but this is going to be code separate from your subpackage. The subpackage can depend on this top-level project, or the top-level project can depend on the subpackage.
Jun 03 2018
On Sunday, 3 June 2018 at 12:08:44 UTC, aliak wrote:The exact error for that setup is: source/app.d(4,9): Error: module `liba` is in file 'lib/liba.d' which cannot be read import path[0] = source/ import path[1] = ../lib/liba/source/ import path[2] = ../lib/libb/source/ import path[3] = /usr/local/opt/dmd/include/dlang/dmd Am I missing sourcePaths or something somewhere?This is a very complicated answer, so I made a pull request instead: https://github.com/aliak00/dub-subpackages/pull/1 lib/liba/source/suba corrected: lib/liba/source/liba/suba
Jun 03 2018
On Sunday, 3 June 2018 at 15:23:52 UTC, Jesse Phillips wrote:On Sunday, 3 June 2018 at 12:08:44 UTC, aliak wrote:Ahhh, I see where I went wrong now. Thanks a lot for the help! And I like the extras you threw in there as well :D Cheers - AliThe exact error for that setup is: source/app.d(4,9): Error: module `liba` is in file 'lib/liba.d' which cannot be read import path[0] = source/ import path[1] = ../lib/liba/source/ import path[2] = ../lib/libb/source/ import path[3] = /usr/local/opt/dmd/include/dlang/dmd Am I missing sourcePaths or something somewhere?This is a very complicated answer, so I made a pull request instead: https://github.com/aliak00/dub-subpackages/pull/1 lib/liba/source/suba corrected: lib/liba/source/liba/suba
Jun 03 2018