Thread overview
How to get serve-d to find dub dependencies
Dec 23
Renato
Dec 23
Renato
December 23

I am trying to use dependencies, so I need dub.

On emacs, the imports from dub libraries cannot be found, even though dub can build it fine.

How can I get emacs/serve-d to "see" the libraries added by dub?

I found that dub has a command for letting the compiler know about the load paths:

dub describe --data=import-paths

This shows the correct paths for the project, so perhaps I can pass this to serve-d somehow?

December 23

On Saturday, 23 December 2023 at 16:13:01 UTC, Renato wrote:

>

I am trying to use dependencies, so I need dub.

On emacs, the imports from dub libraries cannot be found, even though dub can build it fine.

How can I get emacs/serve-d to "see" the libraries added by dub?

I found that dub has a command for letting the compiler know about the load paths:

dub describe --data=import-paths

This shows the correct paths for the project, so perhaps I can pass this to serve-d somehow?

I've managed to kind of hack it by adding the paths to my .dir-locals.el:

((nil . ((indent-tabs-mode . nil)
         (tab-width . 4)))
 (d-mode . ((compile-command . "dmd -L-ld_classic -run")
            (eglot-workspace-configuration . (:importPath ("/Users/renato/.dub/packages/console-colors/1.1.1/console-colors/source/"))))))

Far from ideal but this makes it half work... it actually shows the definitions in the library now and I can even navigate to the source, but still for some reason the import is shown as an error:

Expected 'consolecolors.d' or 'consolecolors/package.d' in one of the following import paths:

I believe that's because this is coming from d-mode, not serve-d (as serve-d actually "sees" it now)?!

Anyway, would love to know how to get serve-d to automatically detect dub libs.

Does the VS Code do that? If it does, this should work also on emacs.

December 24

On Saturday, 23 December 2023 at 16:28:28 UTC, Renato wrote:

>

On Saturday, 23 December 2023 at 16:13:01 UTC, Renato wrote:

>

I am trying to use dependencies, so I need dub.

On emacs, the imports from dub libraries cannot be found, even though dub can build it fine.

How can I get emacs/serve-d to "see" the libraries added by dub?

I found that dub has a command for letting the compiler know about the load paths:

dub describe --data=import-paths

This shows the correct paths for the project, so perhaps I can pass this to serve-d somehow?

I've managed to kind of hack it by adding the paths to my .dir-locals.el:

((nil . ((indent-tabs-mode . nil)
         (tab-width . 4)))
 (d-mode . ((compile-command . "dmd -L-ld_classic -run")
            (eglot-workspace-configuration . (:importPath ("/Users/renato/.dub/packages/console-colors/1.1.1/console-colors/source/"))))))

Far from ideal but this makes it half work... it actually shows the definitions in the library now and I can even navigate to the source, but still for some reason the import is shown as an error:

Expected 'consolecolors.d' or 'consolecolors/package.d' in one of the following import paths:

I believe that's because this is coming from d-mode, not serve-d (as serve-d actually "sees" it now)?!

Anyway, would love to know how to get serve-d to automatically detect dub libs.

dub recently changed how it stores packages. serve-d uses dub as a library to figure this out, so if the dub version serve-d is linked against does not match the version of dub you use to install/build, then it won't find the library includes.

Check your version of dub against the version of dub serve-d is building against.

>

Does the VS Code do that? If it does, this should work also on emacs.

VS Code has a similar problem if you have a mismatch. The solution is to use the beta/nightly release channel of serve-d if you have a recent compiler.

I will note there are some packages that serve-d just can't figure out for imports, because the configuration is done via dflags.

-Steve