SolaWing / xcode-build-server

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

Xcode 15.3 - loading standard library failed error #49

Closed joeldrotleff closed 1 month ago

joeldrotleff commented 2 months ago

Hello,

After upgrading to Xcode 15.3 I am encountering this error. Here is the full text of my lsp.log (I cleared it, restarted Neovim, and this is what I got:

[START][2024-03-15 15:28:37] LSP logging initiated [WARN][2024-03-15 15:28:37] ...lsp/handlers.lua:137 "The language server copilot triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless" [ERROR][2024-03-15 15:28:38] .../vim/lsp/rpc.lua:734 "rpc" "/usr/local/bin/sourcekit-lsp" "stderr" "INFO:root:Xcode Build Server Startup. Waiting Request...\n" [ERROR][2024-03-15 15:28:38] .../vim/lsp/rpc.lua:734 "rpc" "/usr/local/bin/sourcekit-lsp" "stderr" "WARNING:root:observe thread exit by exception: invalid literal for int() with base 10: b'92*{'\n" [ERROR][2024-03-15 15:28:41] .../vim/lsp/rpc.lua:734 "rpc" "/usr/local/bin/sourcekit-lsp" "stderr" "[2024-03-15 15:28:41.184] error response (Request Failed): Loading the standard library failed\n" [ERROR][2024-03-15 15:28:41] .../vim/lsp/rpc.lua:734 "rpc" "/usr/local/bin/sourcekit-lsp" "stderr" '[2024-03-15 15:28:41.187] cursor info failed DocumentURI(storage: file:///Users/joel/code/classmate/ios/Classmate/Classmate/Views/Messaging/MessagesList.swift):7:44: ResponseError(code: LanguageServerProtocol.ErrorCode(rawValue: -32001), message: "sourcekitd request failed: error response (Request Failed): Loading the standard library failed")\n'

Notes:

Hmmmm....tried creating a simple project, one page iOS app from scratch and...LSP works (in that project)...still broken in my app though.

Do you know how I can track this down?

SolaWing commented 2 months ago

[ERROR][2024-03-15 15:28:38] .../vim/lsp/rpc.lua:734 "rpc" "/usr/local/bin/sourcekit-lsp" "stderr" "WARNING:root:observe thread exit by exception: invalid literal for int() with base 10: b'92*{'\n"

I saw this error In your log, this seems to simliar to https://github.com/SolaWing/xcode-build-server/issues/40#issuecomment-1959434102. It should fixed at the commit 9425d7b, and included in release 1.0.1. if your version newer than this commit, you should upload your xcactivitylog to me for debugging it.

joeldrotleff commented 2 months ago

Ok I installed latest with 'brew install Xcode-build-server --head', then cleaned and rebuilt and still seeing the error.

Here's my log 250B0F47-2287-4484-A3DB-4D275B8477C7.xcactivitylog.zip

SolaWing commented 2 months ago

can you run xcode-build-server debug print-xclog <path_to_your_xclog> correctly? also what your buildServer.json likes? is it use your newest brew version?

else you may export SOURCEKIT_LOGGING=3 and see details log to confirm which reason

joeldrotleff commented 1 month ago

Ok so I uninstalled and reinstalled from HEAD to make sure I'm on the latest version: joel@Joels-MacBook-Air ~/c/c/i/C/.n/xcodebuild (main)> brew uninstall --force xcode-build-server Uninstalling xcode-build-server... (13 files, 65KB) joel@Joels-MacBook-Air ~/c/c/i/C/.n/xcodebuild (main)> brew install xcode-build-server --head ==> Fetching xcode-build-server ==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/df7d3165c366af478e8c925379b436dc4e4c4f14/Formula/x/xcode-build-server.rb Already downloaded: /Users/joel/Library/Caches/Homebrew/downloads/9f9ff81d9665c5a45c08269e684a2f383b4a1b3f15d6e587b0ee158f4b59de46--xcode-build-server.rb ==> Cloning https://github.com/SolaWing/xcode-build-server.git Updating /Users/joel/Library/Caches/Homebrew/xcode-build-server--git ==> Checking out branch master Already on 'master' Your branch is up to date with 'origin/master'. HEAD is now at 04ade42 fix: xcode 15.3 clang unfold @ 🍺 /opt/homebrew/Cellar/xcode-build-server/HEAD-04ade42: 13 files, 65.0KB, built in 1 second ==> Running brew cleanup xcode-build-server... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see man brew).

I then ran the command you suggested: joel@Joels-MacBook-Air ~/c/c/i/Classmate (main)> xcode-build-server debug print-xclog ~/Library/Developer/Xcode/DerivedData/Classmate-airajjsuipitpxamfrvcnvhvhqpv

But all it prints is: joel@Joels-MacBook-Air ~/c/c/i/Classmate (main)> xcode-build-server debug print-xclog ~/Library/Developer/Xcode/DerivedData/Classmate-airajjsuipitpxamfrvcnvhvhqpv INFO:root:# xcode builde server with python 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)]]

Here is my buildServer.json:

{ "name": "xcode build server", "version": "0.2", "bspVersion": "2.0", "languages": [ "c", "cpp", "objective-c", "objective-cpp", "swift" ], "argv": [ "/usr/local/bin/xcode-build-server" ], "workspace": "/Users/joel/code/classmate/ios/Classmate/Classmate.xcodeproj/project.xcworkspace", "build_root": "/Users/joel/Library/Developer/Xcode/DerivedData/Classmate-airajjsuipitpxamfrvcnvhvhqpv", "scheme": "Classmate Dev", "kind": "xcode" }

Aslo I tried running this command: extract_compile_log at /Users/joel/Library/Developer/Xcode/DerivedData/Classmate-airajjsuipitpxamfrvcnvhvhqpv/Logs/Build/82842E9F-41EF-4358-B1A0-1282854C0A64.xcactivitylog

And that gives me:

Traceback (most recent call last): File "/usr/local/bin/xcode-build-server", line 58, in main() File "/usr/local/bin/xcode-build-server", line 40, in main xclog_parser.main(subcommand_argv()) File "/Users/joel/code/xcode-build-server/xclog_parser.py", line 478, in main parse(argv) File "/Users/joel/code/xcode-build-server/xclog_parser.py", line 473, in parse within_output_lock(a.output, lambda: _parse(a)) File "/Users/joel/code/xcode-build-server/xclog_parser.py", line 365, in within_output_lock return action() ^^^^^^^^ File "/Users/joel/code/xcode-build-server/xclog_parser.py", line 473, in within_output_lock(a.output, lambda: _parse(a)) ^^^^^^^^^ File "/Users/joel/code/xcode-build-server/xclog_parser.py", line 398, in _parse items = parser.parse() ^^^^^^^^^^^^^^ File "/Users/joel/code/xcode-build-server/xclog_parser.py", line 250, in parse line = next(self._input) # type: str ^^^^^^^^^^^^^^^^^ File "/Users/joel/code/xcode-build-server/xcactivitylog.py", line 88, in extract_compile_log for type, value in tokenizer(path): File "/Users/joel/code/xcode-build-server/xcactivitylog.py", line 80, in tokenizer yield handler(i) ^^^^^^^^^^ File "/Users/joel/code/xcode-build-server/xcactivitylog.py", line 49, in handler length = int(buffer[:index]) ^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: b'78*{'

SolaWing commented 1 month ago

did brew install your xcode-build-server to /usr/local/bin? if not, you should remove it first and rerun your config command to update to use brew path

wojciech-kulik commented 1 month ago

did brew install your xcode-build-server to /usr/local/bin? if not, you should remove it first and rerun your config command to update to use brew path

@SolaWing I think it should be changed to overwrite this path. If you switch between source code and brew it's causing an issue hard to spot. I fell into this trap as well :D

joeldrotleff commented 1 month ago

Ahhh ok mystery solved, I had an old version still installed that was overriding the homebred-installed one. Homebrew installs to /opt-homebrew-bin and symlinks it into /usr/local/bin.

Anyways after running sudo rm -rf /usr/local/bin/xcode-build-server and then xcode-build-server config -project *.xcodeproj -scheme "Classmate Dev", LSP is working now.

Thanks for your help on this @SolaWing and @wojciech-kulik 🙏

SolaWing commented 1 month ago

did brew install your xcode-build-server to /usr/local/bin? if not, you should remove it first and rerun your config command to update to use brew path

@SolaWing I think it should be changed to overwrite this path. If you switch between source code and brew it's causing an issue hard to spot. I fell into this trap as well :D

/usr/local/bin path is prior to brew version and not use.. I won't know which version user really use and can only tip them to check version and ensure uninstall old manual clone version..

wojciech-kulik commented 1 month ago

I meant when user calls xcode-build-server config the path should be updated. What do you think?

SolaWing commented 1 month ago

@wojciech-kulik It indeed updated.. But he use the /usr/local/bin/xcode-build-server is old, not brew version, so config won't change. if he use the brew version and run config, the path will updated to brew version. config will record the same path as the used binary.

wojciech-kulik commented 1 month ago

Oh, got it 👍