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

Windows VSCode do not show error UI. Im new to swift #1226

Closed
wolonge95 opened this issue Nov 27, 2024 · 15 comments
Closed

Windows VSCode do not show error UI. Im new to swift #1226

wolonge95 opened this issue Nov 27, 2024 · 15 comments
Assignees
Labels
bug Something isn't working sourcekit-lsp SourceKit-LSP issue

Comments

@wolonge95
Copy link

error code like below, vscode editor do not show error annotations, seems like nothing wrong, and not show in Problems view.
image

But have this in Output view :
image

Im new to swift. Want to try it. So I install swift follow the instructions on swift.org . Im on windows 11.

I can run "Hello world" in terminal, so I think everything is ok. But vscode spent a lot of time, it does not work as expected.

Expected behavior
Error shows in editor UI, and Problems view.

Environment

  • OS: Windows 11 26100.2454
  • Swift version
    Swift version 6.0.2 (swift-6.0.2-RELEASE)
    Target: x86_64-unknown-windows-msvc
  • Visual Studio Code version: 1.95.3
  • vscode-swift version: 1.11.3 (swift extension from Swift Server Work Group)

Additional context
A few hours ago, I installed everything.

@wolonge95
Copy link
Author

wolonge95 commented Nov 27, 2024

and errors report twice. I do not know it's right or wrong.
image

something in Output view from Swift.

14:28:36: SourceKit-LSP setup
14:28:36: Failed to find C:\Users\wolonge\AppData\Local\Programs\Swift\Toolchains\6.0.2+Asserts\usr\bin\lldb-vscode.exe
14:28:37: swift-executable: add: d:\tmp\swift-executable
14:28:37: swift-executable: Resolving Dependencies: starting ... 
14:28:37: Exec Task: (swift-executable) swift package resolve
14:28:37: swift-executable: focus: d:\tmp\swift-executable
14:28:39: swift-executable: Resolving Dependencies: ... done.

@plemarquand
Copy link
Contributor

Hi, are you building your code from the command line or from within VS Code? You may have to try and build your code once first from within VS Code using either Debug swift-executable or Release swift-executable in the drop down menu with the green play button on the Run and Debug navigator panel.

If that doesn't work and you're still not seeing any problems in the Problems tab could you run > Swift: Capture VS Code Swift Diagnostic Bundle, choose Capture Full Diagnostics, zip up the produced files and then attach them to this issue? Thanks!

@wolonge95
Copy link
Author

Debug swift-executable can show error in editor and Problems tab, but it is not real time.

When I modify the code, the error will not disappear.

vscode-diagnostics-2024-11-29T20-06-14+08-00.zip

@plemarquand
Copy link
Contributor

In your VS Code User settings.json (> Preferences: Open User Settings (JSON)) Could you try setting your "swift.diagnosticsStyle" to "swift" instead of "llvm"?

@wolonge95
Copy link
Author

YES. I try it. Does not work.

By the way, it can show Inline Hint but not error

@award999
Copy link
Contributor

@wolonge95 that output view you pictured is from sourcekit-lsp, if you run the Tasks: Run Task command and select the swift folder and choose a build all task, watch the task terminal, when the build finishes do you see problems?

@award999
Copy link
Contributor

Also although "swift.diagnosticsStyle" can be set to "swift" or "llvm", the "llvm" one is better so we can capture related issues

@wolonge95
Copy link
Author

yes, task outputs problems.

And inline hint works, code completion works, api doc works. Just not show error.

@award999
Copy link
Contributor

award999 commented Dec 3, 2024

@wolonge95 nothing is jumping out. It seems like you should be able to get diagnostics from the language server or tasks. Can you double check you haven't modified settings like outline.problems.enabled or problems.visibility which would prevent diagnostics from being shown

@wolonge95
Copy link
Author

Yeah, I do not change anything. My VSCode works for other languages. settings relate swift:

   "lldb.library": "C:\\Users\\wolonge\\AppData\\Local\\Programs\\Swift\\Toolchains\\6.0.2+Asserts\\usr\\bin\\liblldb.dll",
    "lldb.launch.expressions": "native",
    "swift.diagnosticsStyle": "swift",    // or llvm not work

@Star-Lord-PHB
Copy link

Have the same problem here on Windows 11. The editor inline error can be shown after manually running the build all task, but they are not updated in real time. Even after fixing the error, the inline error messages are still there and I have to manually run the build task again

Screenshot 2024-12-04 at 16 14 59

After manually running build all task

Screenshot 2024-12-04 at 16 15 29

After fixing the error

Screenshot 2024-12-04 at 16 15 38

Using the background compilation can be a workaround, but I don't really like it.

@award999 award999 added the needs investigation Issue requires some investigation before it can be worked on label Dec 5, 2024
@award999
Copy link
Contributor

award999 commented Dec 5, 2024

@wolonge95 @Star-Lord-PHB I was able to reproduce. Debugging on windows, the extension was not getting diagnostics from the language server, raised swiftlang/sourcekit-lsp#1855

@award999 award999 added sourcekit-lsp SourceKit-LSP issue and removed needs investigation Issue requires some investigation before it can be worked on labels Dec 5, 2024
@award999 award999 moved this from Unscreened to Backlog in Swift Extension for Visual Studio Code Dec 5, 2024
@rbenegal
Copy link

rbenegal commented Jan 6, 2025

Seems like swiftlang/sourcekit-lsp#1855 has been fixed, so possibly things are working now. I can look into this again.

@award999 award999 added the needs verification Issue has been fixed, but requires verification before closing label Jan 6, 2025
@award999 award999 moved this from Backlog to Needs Verification in Swift Extension for Visual Studio Code Jan 6, 2025
@rbenegal
Copy link

rbenegal commented Jan 9, 2025

Confirmed that this issue has been fixed in recent versions of the toolchain. Checked with the main branch version of swift-DEVELOPMENT-SNAPSHOT-2025-01-04-a-windows10 on Windows 11:

>ver
Microsoft Windows [Version 10.0.26100.2605]

>swiftc -version
Swift version 6.2-dev (LLVM 06a77c5cc0ff511, Swift 062061e37a8851b)
Target: x86_64-unknown-windows-msvc
Screenshot 2025-01-09 at 10 43 42 AM

For now (as of release 6.0.3) a development snapshot from https://www.swift.org/install/windows/#development-snapshots would be needed to have diagnostic error and warning messages. You may have to uninstall the existing version first to install the new version. Future release versions should work out of the box.

@plemarquand
Copy link
Contributor

Great! Thanks for checking this out @rbenegal.

@plemarquand plemarquand removed the needs verification Issue has been fixed, but requires verification before closing label Jan 9, 2025
@award999 award999 moved this from Needs Verification to Done in Swift Extension for Visual Studio Code Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sourcekit-lsp SourceKit-LSP issue
Development

No branches or pull requests

5 participants