serve-d icon indicating copy to clipboard operation
serve-d copied to clipboard

Issue with LSP4IJ - Could not locate object.d or object.di

Open andre2007 opened this issue 2 months ago • 7 comments

Hi,

I am using CLion and language server plugin LSP4IJ with latest beta of serve-d (serve-d standalone v0.8.0-beta.18)

I configured the plugin like this:

Server:

Image

Mappings:

Image

Configuration:

Image

For a hello world sample application I get this logs:

serve-d standalone v0.8.0-beta.18
Included features: "d", "workspaces"
Built: Fri Oct 18 17:07:32 2024
with compiler LDC v2.109 on win64 x86_64
dub, dfmt and dscanner are bundled within (compiled in)
[progress] [00000.264] [configLoad] 0 / 1: file:///C:/Users/Developer/Desktop/sample1
[progress] [00000.265] [globalStartup]: Initializing serve-d...
2025-10-12T15:51:54.356 [info] source\served\extension.d:533:rootsForProject Root Suggestions: [RootSuggestion("C:\\Users\\Developer\\Desktop\\sample1", true)]
2025-10-12T15:51:54.356 [info] source\served\extension.d:564:doStartup registering instance for root RootSuggestion("C:\\Users\\Developer\\Desktop\\sample1", true)
[progress] [00000.312] [workspaceStartup] 0 / 1: file:///C%3A/Users/Developer/Desktop/sample1
2025-10-12T15:51:54.357 [info] source\served\extension.d:759:delayedProjectActivation Initializing instance for root RootSuggestion("C:\\Users\\Developer\\Desktop\\sample1", true)
[progress] [00000.312] [completionStartup] 0 / 1: file:///C%3A/Users/Developer/Desktop/sample1
[progress] [00000.312] [dubReload] 0 / 1: file:///C:/Users/Developer/Desktop/sample1
2025-10-12T15:51:54.373 [info] source\served\extension.d:892:delayedProjectActivation Root RootSuggestion("C:\\Users\\Developer\\Desktop\\sample1", true) initialized in 16 ms, 357 μs, and 5 hnsecs
[progress] [00000.329] [dubReload] 1 / 1: file:///C:/Users/Developer/Desktop/sample1
[progress] [00000.329] [importReload] 0 / 1: file:///C:/Users/Developer/Desktop/sample1
2025-10-12T15:51:58.480 [info] source\served\extension.d:997:startDCDServer Imports for C:\Users\Developer\Desktop\sample1: ["C:\\Users\\Developer\\Desktop\\sample1\\source\\"]
[progress] [00004.435] [importReload] 1 / 1: file:///C:/Users/Developer/Desktop/sample1
[progress] [00004.454] [configFinish] 1 / 1: 
2025-10-12T15:51:59.075 [warning] C:\Users\runneradmin\AppData\Local\dub\packages\dcd\0.16.0-beta.2\dcd\dsymbol\src\dsymbol\conversion\first.d:377:visit Could not locate object.d or object.di
2025-10-12T15:51:59.075 [warning] C:\Users\runneradmin\AppData\Local\dub\packages\dcd\0.16.0-beta.2\dcd\dsymbol\src\dsymbol\conversion\first.d:474:visit Could not resolve location of module 'std\stdio'

Please note the issue about the missing location of object.d and std\stdio. Interestingly while clicking with CTRL + left mouse click on import std.stdio the source code file of stdio.d is opened.

andre2007 avatar Oct 12 '25 13:10 andre2007

@andre2007 to have the same config than vscode, I suggest that you install vscode d extension and you active LSP trace by adding the settings "serve-d.trace.server": "verbose". You should see trace in the Ouptput channel.

angelozerr avatar Oct 13 '25 11:10 angelozerr

good tipp. I tried and saw in the logs this:

 {
    "settings": {
        "d": {
            "servedPath": "C:\\Users\\Developer\\AppData\\Roaming\\code-d\\bin\\serve-d.exe",
            "stdlibPath": "auto",

I tried in the plugin with and without "settings". I also tried value "auto". So far without success.

andre2007 avatar Oct 13 '25 15:10 andre2007

You must remove "settings": section.

angelozerr avatar Oct 13 '25 15:10 angelozerr

I think I found the issue. It seems it is not necessary to set any settings, it is auto detected. But before it is auto detected, there is the "false positive?" warning in the log.

2025-10-13T17:58:37.823 [warning] C:\Users\runneradmin\AppData\Local\dub\packages\dcd\0.16.0-beta.2\dcd\dsymbol\src\dsymbol\conversion\first.d:377:visit Could not locate object.d or object.di
2025-10-13T17:58:37.823 [warning] C:\Users\runneradmin\AppData\Local\dub\packages\dcd\0.16.0-beta.2\dcd\dsymbol\src\dsymbol\conversion\first.d:474:visit Could not resolve location of module 'std\stdio'
...
2025-10-13T17:58:40.137 [trace] source\served\extension.d:978:startDCDServer Running DCD setup
2025-10-13T17:58:40.137 [trace] source\served\utils\stdlib_detect.d:51:autoDetectStdlibPaths falling back to global imports search
[progress] [00002.839] [importReload] 0 / 1: file:///C:/Users/Developer/Desktop/sample1
2025-10-13T17:58:40.137 [trace] source\served\utils\stdlib_detect.d:332:parseDmdConfImports test dmd conf C:\dlang\dmd2\windows\bin64\sc.ini
2025-10-13T17:58:40.137 [trace] source\served\utils\stdlib_detect.d:54:autoDetectStdlibPaths found stdlib paths in DMD or LDC: ["C:\\dlang\\dmd2\\windows\\bin64\\..\\..\\src\\phobos", "C:\\dlang\\dmd2\\windows\\bin64\\..\\..\\src\\druntime\\import"]
2025-10-13T17:58:40.137 [trace] source\served\extension.d:983:startDCDServer startServer ["C:\\dlang\\dmd2\\windows\\bin64\\..\\..\\src\\phobos", "C:\\dlang\\dmd2\\windows\\bin64\\..\\..\\src\\druntime\\import"]

andre2007 avatar Oct 13 '25 16:10 andre2007

I wonder if serve-d community could be interested to consume easily serve-d in IntelliJ with LSP4IJ? If yes, you could contribute to default template

See https://github.com/redhat-developer/lsp4ij/blob/main/docs/UserDefinedLanguageServerTemplate.md for more info.

You could even write a JSON installer to install automaticly the server like installer of TypeScript Language Server

Contributing with default template, will mean that user wil just require to open a d file and you will see an editor notification which will promote to install the language server (see for instance https://github.com/redhat-developer/lsp4ij/blob/main/docs/user-defined-ls/astro-ls.md#step-1-install-the-language-server)

Image

angelozerr avatar Oct 13 '25 17:10 angelozerr

This was my plan, after getting some experience with it and checking that everything is working smoothly.

Together with the LSP protocol, syntax highlighting with the Textmate Bundle and the debugging via LLDB (Debug Adapter Protocol) the Jetbrains IDEs might become a quite interesting alternative.

andre2007 avatar Oct 13 '25 18:10 andre2007

This was my plan, after getting some experience with it and checking that everything is working smoothly.

If you need some help please ask me. You can also define a JSON Schema in the client JSON editor and I suggest that you use split checkbox to copy/paste vscode settings in LSP4IJ Client editor.

Together with the LSP protocol, syntax highlighting with the Textmate Bundle and the debugging via LLDB (Debug Adapter Protocol) the Jetbrains IDEs might become a quite interesting alternative.

Indeed, LSP4IJ provides also DAP support, see https://github.com/redhat-developer/lsp4ij/blob/main/docs/dap/user-defined-dap/codelldb.md

angelozerr avatar Oct 13 '25 18:10 angelozerr