Pure-D / serve-d

D LSP server (dlang language server protocol server)
MIT License
200 stars 48 forks source link

Cannot use dub with invalid configuration #191

Closed webloft closed 1 year ago

webloft commented 2 years ago

I have a dub.sdl looking like this:

name "abc"
license "proprietary"
targetType "none"
importPaths "code"

subPackage {
    name "xyz"
    targetType "dynamicLibrary"
    targetPath "../../build/$BUILD_TYPE"
    importPaths "code"
    sourcePaths "packages/lib-common"
    versions "common"
    dflags "-i"
    copyFiles "..." platform="windows"
}
...

That file is valid, no problems running it via dub but serve-d yells about an invalid configuration without further information:

serve-d v0.7.4 with workspace-d v3.7.0
Included features: "d", "workspaces"
Built: Sat Jan  8 02:43:14 2022
...
[error] source\served\extension.d:792:delayedProjectActivation Exception starting dub: object.Exception@C:\Users\runneradmin\AppData\Local\dub\packages\workspace-d-3.7.0\workspace-d\source\workspaced\com\dub.d(242): Cannot use dub with invalid configuration

The folder code is in the same directory as dub.sdl.

WebFreak001 commented 2 years ago

the targetType "none" means your package doesn't (shouldn't) have code, so it isn't loaded.

The subpackage should be loaded though when you open a file in it, and auto completion should work.

webloft commented 2 years ago

No, it doesn't. It only works if I change the targetType to something other. However, "none" is a valid value and should be respected.

WebFreak001 commented 2 years ago

the exception is actually to prevent a harder crash that occurs when you try to use a package like this.

The root package definitely shouldn't be loaded for code editing, but the subpackage should be loaded and needs to be checked why it isn't loaded right now.

webloft commented 2 years ago

And If I load a common file that is used in package A and B but not within the sub-directory structure of any package, how it is supposed to load a package then? Is loading the package required to make auto-completion working? The specs says "none" is not generate an output file, nothing about there should be no code.

WebFreak001 commented 2 years ago

you can't have common files in a none subpackage, use sourceLibrary instead

webloft commented 2 years ago

I tried that. The error disappears at startup but auto-completion works not with import. At least not for the last hour. And dcd-server stays open at exit of serve-d. I don't know if it's supposed to be re-used but it also spawns new instances.

It still logs: [error] serverbase\source\served\serverbase.d:338:__lambda2 Failed processing notification: object.Exception@C:\Users\runneradmin\AppData\Local\dub\packages\workspace-d-3.7.0\workspace-d\source\workspaced\com\dub.d(253): Cannot build with dub with targetType == sourceLibrary

0xEAB commented 2 years ago
name "test"
targetType "none"

subPackage {
    name "mycode"
    sourcePaths "source"
    importPaths "source"
    targetType "executable"
}
dependency ":mycode" version="*"

dub builds fine, makes serve-d error though

Dub Error: No configuration available
2022-06-05T22:09:40.057 [error] extension.d:792:delayedProjectActivation Exception starting dub: object.Exception@workspace-d-3.7.0/workspace-d/source/workspaced/com/dub.d(242): Cannot use dub with invalid configuration
0xEAB commented 2 years ago

stacktrace on latest commit:

Dub Error: No configuration available
2022-06-06T02:23:17.657 [error] extension.d:793:delayedProjectActivation Exception starting dub: object.Exception@workspace-d/source/workspaced/com/dub.d(246): Cannot use dub with invalid configuration
----------------
??:?
??:?
??:?
workspace-d/source/workspaced/com/dub.d:246
source/served/extension.d:782
source/served/extension.d:694
source/served/backend/lazy_workspaced.d:137
source/served/backend/lazy_workspaced.d:79
workspace-d/source/workspaced/backend.d:180
workspace-d/source/workspaced/backend.d:429
source/served/extension.d:168
source/served/extension.d:276
source/served/extension.d:225
serverbase/source/served/utils/events.d:136
serverbase/source/served/serverbase.d:291
serverbase/source/served/utils/events.d:150
serverbase/source/served/utils/events.d:297
serverbase/source/served/utils/events.d:121
serverbase/source/served/serverbase.d:288
serverbase/source/served/serverbase.d:334
??:?
??:?

(unspectacular, not sure what I was expecting)

WebFreak001 commented 1 year ago

tracking targetType none + subPackage issue in #304 now