SolaWing / xcode-build-server

a build server protocol implementation for integrate xcode with sourcekit-lsp
MIT License
424 stars 19 forks source link

v1.0.0 via Homebrew requires to set up a symlink manually #39

Closed wojciech-kulik closed 9 months ago

wojciech-kulik commented 9 months ago

I switched to the latest version from Homebrew and I get:

[ERROR][2024-02-20 11:45:40] .../vim/lsp/rpc.lua:734    "rpc"   "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp"  "stderr"    '[2024-02-20 11:45:40.473] failed to start build server: Error Domain=NSCocoaErrorDomain Code=4 "The file “xcode-build-server” doesn’t exist." UserInfo={NSFilePath=/usr/local/bin/xcode-build-server}\n[2024-02-20 11:45:40.473] could not find manifest, or not a SwiftPM package: /Users/wkulik/repositories/MyApp/dev\n'
[ERROR][2024-02-20 11:45:40] .../vim/lsp/rpc.lua:734    "rpc"   "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp"  "stderr"    "[2024-02-20 11:45:40.864] could not open compilation database for /Users/wkulik/repositories/MyApp/dev/MyAppLib/Modules/Lib/MyFile.swift\n"

It turns out that I had to manually create a symlink:

sudo ln -s /opt/homebrew/bin/xcode-build-server /usr/local/bin

Is it possible to make it automatically via Homebrew? If not then it should be documented in the readme.

wojciech-kulik commented 9 months ago

Ah, the problem is with generated buildServer.json. It sets incorrect path:

"argv": [
    "/usr/local/bin/xcode-build-server"
],

but it should be:

/opt/homebrew/bin/xcode-build-server
SolaWing commented 9 months ago

did /opt/homebrew/bin add into your PATH?

argv is read by your command absolute path. so if which xcode-build-server is in /use/local/bin, the argv will be there. if you prefer brew version, should ensure PATH contains /opt/homebrew/bin, and ensure which xcode-build-server refer to it

wojciech-kulik commented 9 months ago

I switched from local version. It looks like this path is not being updated, once it's configured. I removed the buildServer.json regenerated it and now it correctly points to homebrew location.

wojciech-kulik commented 9 months ago

One more thing. I noticed that Xcode Build Server Startup. Waiting Request... is logged to stderr which makes it appear in LspLog as an error. Could it be changed? It's not an error after all.

[START][2024-02-20 12:10:04] LSP logging initiated
[ERROR][2024-02-20 12:10:04] .../vim/lsp/rpc.lua:734    "rpc"   "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp"  "stderr"    "INFO:root:Xcode Build Server Startup. Waiting Request...\n"
SolaWing commented 9 months ago

I switched from local version. It looks like this path is not being updated, once it's configured. I removed the buildServer.json regenerated it and now it correctly points to homebrew location.

I push a commit to always update basic info. but it will only effect when next formal release. now have to remove and regenerate it.

is logged to stderr which makes it appear in LspLog as an error. Could it be changed? It's not an error after all.

for log, xcode-build-server need a place to show. since stdout is occupied by communicate with lsp, the convenience output only left stderr. It just log, log level will output in log too. if this really annoy, may need to provide a config to redirect the log..

wojciech-kulik commented 9 months ago

It would be nice to keep those entries out of LspLog. Every time I need to find an actual problem in LspLog, I see tons of false errors from xcode-build-server, so I guess the best option would be to log them to some other file and forward to LspLog only true errors.

But it's not a must-have :).

SolaWing commented 9 months ago

newest Head add a environment XBS_LOGPATH, which can redirect all logs. set to :null to disable it.

wojciech-kulik commented 9 months ago

Thank you! 🍻