www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dub import local D package

reply data pulverizer <data.pulverizer gmail.com> writes:
Hi all,

I'm trying to import a local dub package into a dub project 
(`json` format). I have added the package I'm trying to import 
with `dub add-local` and `dub add-path` and including it within 
the json file, but I get the error

```
$ dub build
Performing "debug" build using /.../ldc2/bin/ldc2 for x86_64.
myPackageName 0.1.0: target for configuration "library" is up to 
date.
test ~master: building configuration "application"...
source/app.d(1,8): Error: module `mymodule` is in file 
'myPackageName/modules/mymodule.d' which cannot be read
import path[0] = source/
import path[1] = ../myPackageName/source/
import path[2] = /.../ldc2/bin/../import
/.../ldc2/bin/ldc2 failed with exit code 1.
```

The dependencies in the dub.json file looks like this:


```
	"dependencies": {
		"myPackageName": {
			"path": "/.../myPackageName",
			"version": "0.1.0"
		}
	}
```

Thanks in advance
Apr 20 2022
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 4/20/22 7:39 PM, data pulverizer wrote:
 Hi all,
 
 I'm trying to import a local dub package into a dub project (`json` 
 format). I have added the package I'm trying to import with `dub 
 add-local` and `dub add-path` and including it within the json file, but 
 I get the error
 
 ```
 $ dub build
 Performing "debug" build using /.../ldc2/bin/ldc2 for x86_64.
 myPackageName 0.1.0: target for configuration "library" is up to date.
 test ~master: building configuration "application"...
 source/app.d(1,8): Error: module `mymodule` is in file 
 'myPackageName/modules/mymodule.d' which cannot be read
 import path[0] = source/
 import path[1] = ../myPackageName/source/
 import path[2] = /.../ldc2/bin/../import
 /.../ldc2/bin/ldc2 failed with exit code 1.
 ```
 
 The dependencies in the dub.json file looks like this:
 
 
 ```
      "dependencies": {
          "myPackageName": {
              "path": "/.../myPackageName",
              "version": "0.1.0"
          }
      }
 ```
 
 Thanks in advance
Did you substitute something real with `...` to hide it from your post? Because that's not a real path. Note that if you use path dependencies, you do not have to dub add-local the package. -Steve
Apr 20 2022
parent reply data pulverizer <data.pulverizer gmail.com> writes:
On Thursday, 21 April 2022 at 00:14:16 UTC, Steven Schveighoffer 
wrote:
 Did you substitute something real with `...` to hide it from 
 your post? Because that's not a real path.
I used it to hide my actual paths.
Apr 20 2022
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 4/20/22 9:53 PM, data pulverizer wrote:
 On Thursday, 21 April 2022 at 00:14:16 UTC, Steven Schveighoffer wrote:
 Did you substitute something real with `...` to hide it from your 
 post? Because that's not a real path.
I used it to hide my actual paths.
OK, so reviewing with that in mind, it looks like you're trying to import `myPackage.modules.mymodule`, but the file `../myPackageName/source/myPackageName/modules/mymodule.d` doesn't exist. Is there one too many "myPackageName" packages here? There also could be a typo somewhere, but that is masked by the fact that you substituted all the real names with these fake ones. -Steve
Apr 20 2022
parent data pulverizer <data.pulverizer gmail.com> writes:
On Thursday, 21 April 2022 at 03:59:26 UTC, Steven Schveighoffer 
wrote:
 OK, so reviewing with that in mind, it looks like you're trying 
 to import `myPackage.modules.mymodule`, but the file 
 `../myPackageName/source/myPackageName/modules/mymodule.d` 
 doesn't exist.

 Is there one too many "myPackageName" packages here?
Yes, looks like that it works if I change to `import modules.mymodule;`.
Apr 21 2022