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

When using dub, a project in the workspace root is required. Make it optional. #374

Open
Reavershark opened this issue Jul 8, 2024 · 1 comment

Comments

@Reavershark
Copy link

Because I'm using an external build system (esp-idf), my dub project is a subdirectory in the workspace.
Serve-d finds it just fine (with d.scanAllFolders) and uses it as a dub project, but gives an error when trying to set up the workspace folder as a project, which has no dub.sdl/json.

Currently there is no way to prevent the root folder being used as dub project (without d.neverUseDub).

One solution would be to not force add the workspace as a project, relying instead on d.scanAllFolders to find a dub.sdl/json in the workspace root. This would break projects using "d.scanAllFolders": false and not including "." in the d.extraRoots:

diff --git a/source/served/extension.d b/source/served/extension.d
index 715128e..a1a8d1d 100644
--- a/source/served/extension.d
+++ b/source/served/extension.d
@@ -506,31 +506,28 @@ RootSuggestion[] rootsForProject(string root, bool recursive, string[] blocked,
                if (!ret.canFind!(a => a.dir == dir))
                        ret ~= RootSuggestion(dir, useDub);
        }

-       bool rootDub = dubRecipeExists(root, true);
-       addSuggestion(root, rootDub);
-
        if (recursive)
        {
                foreach (pkg; tryDirEntries(root, "dub.{json,sdl}", fs.SpanMode.breadth))
                {
                        auto dir = dirName(pkg);
                        if (dir.canFind(".dub"))
                                continue;
-                       if (dir == root)
-                               continue;
                        if (blocked.any!(a => globMatch(dir.relativePath(root), a)
                                        || globMatch(pkg.relativePath(root), a) || globMatch((dir ~ "/").relativePath, a)))
                                continue;
                        addSuggestion(dir, true);
                }
        }

Alternatively, another config option could be added to always include the workspace root as dub project, defaulting to true.

@Reavershark
Copy link
Author

It seems that a project in the workspace root is assumed to exist by onDidSaveDubRecipe and possibly in more places.

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

1 participant