Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not initialize dub … for no (obvious) reason #459

Open
0xEAB opened this issue Jun 22, 2023 · 11 comments
Open

Could not initialize dub … for no (obvious) reason #459

0xEAB opened this issue Jun 22, 2023 · 11 comments

Comments

@0xEAB
Copy link

0xEAB commented Jun 22, 2023

Could not initialize dub for /home/elias/dev/linedubbed2. Falling back to limited functionality!

Dub package failed to load or no configurations are available, cannot list import paths needed for build and auto-complete.

Error details
com=dub: 0: Dub Error: No configuration available 
2023-06-22T21:18:36.896 [error] extension.d:664:delayedProjectActivation Exception starting dub: object.Exception@workspace-d/source/workspaced/com/dub.d(353): Dub package failed to load or no configurations are available, cannot list import paths needed for build and auto-complete.
2023-06-22T21:18:36.896 [error] extension.d:672:delayedProjectActivation Failed starting dub in RootSuggestion("/home/elias/dev/linedubbed2", true) - falling back to fsworkspace
dub.json
{
    "name": "linedubbed2",
    "description": "lineDUBbed – DUB package testing system",

    "copyright": "Copyright © 2023 Elias Batek",
    "license": "BSL-1.0",

    "authors": [
        "Elias Batek"
    ],

    "targetPath": "bin",
    "targetType": "none",

    "dependencies": {"linedubbed2:common": "*"},

    "subPackages": [
        {
            "name": "controller",
            "description": "Central controller",
            "importPaths": ["controller"],
            "sourcePaths": ["controller"],
            "targetPath": "bin",
            "targetType": "executable",
            "dependencies": {
            }
        },
        {
            "name": "runner",
            "description": "Test runner",
            "importPaths": ["runner"],
            "sourcePaths": ["runner"],
            "targetPath": "bin",
            "targetType": "executable",
            "dependencies": {
                "linedubbed2:common": "*",
                "requests": "~>2.0"
            }
        },
        {
            "name": "common",
            "description": "Common library",
            "importPaths": ["common"],
            "sourcePaths": ["common"],
            "targetPath": "bin",
            "targetType": "library",
            "dependencies": {
            }
        }
    ]
}

But it builds just fine:

$ dub build :common
    Starting Performing "debug" build using /opt/ldc2/bin/ldc2 for x86_64.
  Up-to-date linedubbed2:common ~main: target for configuration [library] is up to date.
$ dub build :runner
    Starting Performing "debug" build using /opt/ldc2/bin/ldc2 for x86_64.
  Up-to-date linedubbed2:common ~main: target for configuration [library] is up to date.
  Up-to-date automem 0.6.9: target for configuration [library] is up to date.
  Up-to-date cachetools 0.4.1: target for configuration [library] is up to date.
  Up-to-date requests 2.0.9: target for configuration [std] is up to date.
  Up-to-date linedubbed2:runner ~main: target for configuration [application] is up to date.
    Finished To force a rebuild of up-to-date targets, run again with --force
$ dub build :controller
    Starting Performing "debug" build using /opt/ldc2/bin/ldc2 for x86_64.
  Up-to-date linedubbed2:controller ~main: target for configuration [application] is up to date.
    Finished To force a rebuild of up-to-date targets, run again with --force
$ dub build
    Starting Performing "debug" build using /opt/ldc2/bin/ldc2 for x86_64.
  Up-to-date linedubbed2:common ~main: target for configuration [library] is up to date.
    Finished To force a rebuild of up-to-date targets, run again with --force
@WebFreak001
Copy link
Member

problem might be "targetType": "none"

@0xEAB
Copy link
Author

0xEAB commented Jun 22, 2023

seems so. though if I change it to library, it goes completely rogue:

com=dub: 2: Error while listing import paths object.Exception@../../.dub/packages/dub-1.31.0/dub/source/dub/generators/generator.d(392): Package with target type "none" must have dependencies to build.

Like there’s not a single mention of none anywhere in the recipe…

@0xEAB
Copy link
Author

0xEAB commented Jun 23, 2023

From my perception, code-d seems to come with the assumption that the main package will not be target "none" and depend on all of its subpackages.

code-d does not seem to bother resolving dependencies of subpackages (unless the main package depends on them).

@WebFreak001
Copy link
Member

code-d can find the subpackages and initialize them like the main package by searching for dub.json and dub.sdl files inside the folder, and should do so by default, did you change anything in your user settings?

@0xEAB
Copy link
Author

0xEAB commented Jun 23, 2023

{
    "d.dubCompiler": "ldc2",
    "d.stdlibPath": "/opt/ldc2/import",
    "d.dubPath": "/usr/bin/dub",
    "d.servedPath": "/home/elias/.local/share/code-d/bin/serve-d",
    "d.servedReleaseChannel": "beta",
    "d.dcdClientPath": "/home/elias/.local/share/code-d/bin/dcd-client",
    "d.dcdServerPath": "/home/elias/.local/share/code-d/bin/dcd-server",
}

@0xEAB
Copy link
Author

0xEAB commented Jun 23, 2023

Fails to resolve/locate a bunch of things:

2023-06-23T18:49:17.788 [info] extension.d:516:rootsForProject Root Suggestions: [RootSuggestion("/home/elias/dev/linedubbed2", true)]
2023-06-23T18:49:17.788 [info] extension.d:548:doStartup registering instance for root RootSuggestion("/home/elias/dev/linedubbed2", true)
2023-06-23T18:49:17.788 [info] extension.d:638:delayedProjectActivation Initializing instance for root RootSuggestion("/home/elias/dev/linedubbed2", true)
2023-06-23T18:49:17.878 [info] extension.d:709:delayedProjectActivation Root RootSuggestion("/home/elias/dev/linedubbed2", true) initialized in 89 ms and 428 μs
2023-06-23T18:49:17.904 [info] extension.d:805:startDCDServer Imports for /home/elias/dev/linedubbed2: ["/home/elias/dev/linedubbed2/common"]
2023-06-23T18:49:18.812 [warning] first.d:376:visit Could not locate object.d or object.di
2023-06-23T18:49:18.812 [warning] first.d:473:visit Could not resolve location of module 'linedubbed/controller/mvc/controllers'
2023-06-23T18:49:18.812 [warning] first.d:473:visit Could not resolve location of module 'oceandrift/http/microframework/app'
2023-06-23T18:51:19.404 [info] code_actions.d:228:addDScannerDiagnostics Diagnostic: Diagnostic([Position(36, 52), Position(36, 57)], hint, dscanner.suspicious.unused_parameter, void, DScanner, "Parameter group is never used.", void, [unnecessary], void)
2023-06-23T18:57:28.556 [warning] first.d:376:visit Could not locate object.d or object.di
2023-06-23T18:57:28.556 [warning] first.d:473:visit Could not resolve location of module 'linedubbed/controller/mvc/controllers'
2023-06-23T18:57:28.556 [warning] first.d:473:visit Could not resolve location of module 'oceandrift/http/microframework/app'

@0xEAB
Copy link
Author

0xEAB commented Jun 23, 2023

might be related to #458 – as it seems like code-d has no clue where modules of the subpackage are actually located

@0xEAB
Copy link
Author

0xEAB commented Jun 24, 2023

After some severe experimenting, I came to the conclusion, that DUB and/or serve-d starts acting weird when your root package doesn’t have any source files.

Weird in terms of picking up only some dependencies/subpackages/imports.

@0xEAB
Copy link
Author

0xEAB commented Jun 24, 2023

Also it certainly doesn’t like subpackages with a target type of "executable"

@0xEAB
Copy link
Author

0xEAB commented Jun 25, 2023

I’ve worked around all these issues by adding configurations in addition to the subpackages.
oceandrift/linedubbed2@f2b51db

@Superbelko
Copy link

My case is a main dub.json at root folder that serving as a collection of subpackages with source files in subfolders, they all depend on a core package with basic declarations, but everything else is implemented by other subpackages, the goal is to have single place to build which by default achieved by targetType none in the presence of subpackages.

Thanks to @0xEAB for an example, as it seems code-d can't work with main dub recipe if targetType set to none, but seems to work if I remove target type and instead just add an empty configuration with targetType none.

With this approach I can still build as simple as dub build and auto-completion is working, yay \0/

dub.json:

{
    "authors": [
        "Superbelko"
    ],
    "copyright": "Copyright © 2023, Superbelko",
    "description": "Core game library",
    "license": "proprietary",
    "name": "game",
    
    "targetPath": ".junk", // just in case some intermediate files generated, I absolutely don't want to publish them
    "subPackages": [
        { 
            "name": "core",
            "sourcePaths": ["coregame/source"],
            // ...
        }
    ],
    "dependencies": {
        "game:core": "*"
    },
    "configurations": [
        { 
            "name": "default",
            "targetType": "none"
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants