Closed wojciech-kulik closed 2 months ago
seems no logs from xcode-build-server? also notice you have exceeded call rate limit of your current OpenAI, did this will break your completion?
also notice you have exceeded call rate limit of your current OpenAI, did this will break your completion?
This is weird because I don't remember using any OpenAI plugin :D. I'm using just Copilot. Update: Oh, I forgot that GitHub Copilot uses OpenAI.
How about:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 change listeners added to [EventEmitter]
any idea what could it be?
Memory leaks usually do not affect functionality
I keep having issues with LSP that stops working on my project and I've been thinking that maybe it's related to those logs.
I will try to test it a little bit more and let you know.
How about other errors (besides OpenAI & leaks). Any ideas?
Did you tried clean build directory, xcode-build-server cache directory and rebuild? I recently find sometimes lsp work very slow and often unresponsive. after a full clean and rebuild, it’s ok
Yes, I usually do clean build from Xcode if something breaks, but it doesn't help for long. How can I clean xcode-builld-server cache - where it is?
Right now for example, the LSP works partially, some navigation works, but for some things LSP can't find definition, even for a simple class. I did clean build and run xcode-build-server config
again. I tried also to call xcode-build-server parse
manually.
It looks like right now LSP is not able to find definitions from other xcframeworks. It is able only to navigate within the same module.
How can I clean xcode-builld-server cache - where it is?
It’s at ~/Library/Caches/xcode-build-server. it contains compile file from logs, and index database from lsp.
Still no luck, I removed cached, run clean build, restarted Neovim and it's still unable to navigate to another modules:
[telescope.builtin.lsp_definitions]: No LSP Definitions found
but I can navigate with no issue from Xode.
did you have correctly flags pass to LSP? had any error with environment SOURCEKIT_LOGGING=3?
I'm not sure what I should be looking for there. With this logging level, logs are messy. They print source code, everything is an error and it's not in a readable form, so it's hard to judge what's going on there. Also, what are "correct" flags :D? What should be expected there.
correct flags should be same as the build command for the file.
if flags is correct, and cache is clean, may check using same version for xcode and sourcekit-lsp. also you can check another editor like vscode vs swift plug-in to ensure not lsp’s fault
Flags seem to be similar, it's hard to compare them manually. Although I also tried to perform another clean build from Xcode, export logs and parse them manually using xcode-build-server to ensure that everything is the same, but still no luck. Navigation works only in the same module (xcframework) if I try navigate outside it can't find symbols. The same issue occurs in Visual Studio (but ofc it's the same tool: sourcekit-lsp + xcode-build-server), but in Xcode everything works perfect.
I've also got another project, but it's different, it's built using modularization with SPM packages and there cross-module navigation works without any issues.
I also checked another project with xcframeworks and it works fine. So it looks like, LSP doesn't like my one specific project for some reason...
I don't know what else I can try. It worked before but it stopped working now.
Therefore it only reproduces in a specific private repository of yours... and is fine in other repositories..
Cross-module symbols are generally related to the index-store in compilation. Maybe your specific data triggers some kind of bug in sourcekit.
Use SOURCEKIT_LOGGING=3 to look at the detailed logs to see if there are any clues
If you have the smallest reproducible demo, I can also try to debug it to see if I have the same problem here.
Nothing interesting with this env either. Just:
'sourcekit: [2:sourcekitd_send_request-after:5635:10.9803] {\n key.internal_diagnostic: "Resolved to incomplete expression or statement."\n}\n'
'[2024-09-03 21:04:43.869] {\n key.internal_diagnostic: "Resolved to incomplete expression or statement."\n}\n'
"[2024-09-03 21:04:43.870] SourceKitServer: Response<textDocument/definition(2)>(\n success(Optional(LanguageServerProtocol.LocationsOrLocationLinksResponse.locations([])))\n)\n"
Is it possible to access the index like a normal DB? I think I saw something like that in the past. Maybe I could check if specific symbols are correctly mapped?
Symbols are correctly indexed. I managed to check example symbol if the index shows that it is referenced in the file from which I can't navigate to it.
I did it using: https://github.com/mikolasstuchlik/GLibISDemo/tree/master
symbols may coming from https://github.com/swiftlang/indexstore-db, although I haven't read it's code.
The final solution may be to debug Sourcekit-lsp and add more logs to see what is wrong.
Also note that the bottom layer of LSP depends on Sourcekit. Although jump and completion have the same symbols, the dependent codes are different. You can confirm whether your completion is ok. If it is ok, it is just a problem of LSP using indexdb. If it's not ok, it may be a problem with the underlying SourceKit. SourceKit itself also provides a YAML request interface, which can be requested directly using tools such as https://github.com/jpsim/SourceKitten. Theoretically, there should be no exceptions if the parameters are correct, but sourcekitten may not support some parameters, causing exceptions.
It looks like LSP doesn't provide completions for those symbols from other modules either.
I haven't figured out how to use SourceKitten with my project, but I think there is a simpler way to test lsp. I can call it using Neovim API:
vim.lsp.buf_request_all(BUF_NR, "workspace/symbol", { query = "AppError" }, function(result)
P(result)
end)
In my case it doesn't find that symbol in other modules. So it looks like a problem with sourcekit-lsp. Or I guess potentially it could be also caused by the lack of information from xcode-build-server
? I don't fully understand how it works under the hood, but as far as I understand xcode-build-server
allows sourcekit-lsp to understand the project structure and be able to provide the cross-module search, etc.
Is there any way to determine on which side there is an issue?
I also sniffed what is sent via vim.lsp.buf_requets_all
when I hit gd
and it's:
vim.lsp.buf_request_all(BUF_NR, "textDocument/definition", {
position = {
character = 45,
line = 73,
},
textDocument = {
uri = "file:///PATH_TO_MY_FILE",
},
}, function(result)
P(result)
end)
and the result
is empty :(
All xcode-build-server can do is provide flags to sourcekit-lsp. If there is no problem with the flags provided by sourceKitOptionsChanged and they are consistent with the swiftc compilation command, then it is basically not a problem with xcode-build-server.
LSP depends on sourcekit, which is a service that can be requested independently. Use SOURCEKIT_LOGGING=3 to see detailed interface requests for interacting with it. If its request parameters are provided correctly but there is no correct result, it may be a bug in Swift itself. If the sourcekit is normal and there are errors elsewhere in the log, it may be an LSP problem. In addition, cross-module symbol search is done in indexdb, which has nothing to do with sourcekit. But completion is provided by sourcekit. So if the completion is normal but only the jump is abnormal, then there is a high probability that there is a problem with indexdb. If it is not normal, then there may be a problem with sourcekit or indexstore.
In the end, it is best to have a reproducible demo project to debug and locate problems.
In addition, from your log, you only provided part of the log. It seems that Cursor.swift:620: Fatal error is abnormal?
I guess, my project somehow breaks sourcekit. A minimum reproducible demo is not very likely, as it works with other projects. I will have to live with that for now. Maybe the new Swift & sourcekit-lsp will solve this problem.
Thank you for all your help and great tips!
I updated macOS to Sequoia and Xcode to 16 and it suddenly all works 🎊. Probably it was a bug and they fixed that. Also, finally, the smart rename is available in the latest version of sourcekit-lsp ^^.
Hi! I'm getting recently some issues from LSP.
Any idea what could be causing it? I'm not sure if it's something xcode-build-server related or not.