pwsacademy / swift-setup

Student-friendly setup instructions for platforms, editors, and IDEs that support Swift.
150 stars 11 forks source link

ENOENT; missing serverPath #3

Closed idelfonsog2 closed 3 years ago

idelfonsog2 commented 3 years ago
ENOENT: no such file or directory, stat 'sourcekit-lsp.serverPath'

editor: VSCode

I'm getting the above warning. In my project VsCode has requested me to create two files in order to debug my vapor application in it, which look like the following:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug",
            "program": "${workspaceFolder}/TILApp",
            "args": [],
            "cwd": "${workspaceFolder}"
        }
    ]
}
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "swift build",
            "type": "shell",
            "command": "swift build",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

The SourceKitLSP settings look like the following:

Any suggestions?

svanimpe commented 3 years ago

I did a quick check, and it turns out that sourcekit-lsp isn't on the PATH on macOS. However, the following setting does work fine for me:

"sourcekit-lsp.serverPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp",

Did you verify this file exists? That is, I assume you have Xcode installed, as well as its command line tools?

svanimpe commented 3 years ago

Also, see the instructions for VS Code for a correct launch.json configuration. I assume your program setting is incorrect and that you're missing a preLaunchTask setting?

idelfonsog2 commented 3 years ago

I did a quick check, and it turns out that sourcekit-lsp isn't on the PATH on macOS. However, the following setting does work fine for me:

"sourcekit-lsp.serverPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp",

Did you verify this file exists? That is, I assume you have Xcode installed, as well as its command line tools?

Thank you for the quick response @svanimpe !

I added to my $PATH: /Users/idelfonso/anaconda3/bin:/Users/idelfonso/anaconda3/condabin:/Users/idelfonso/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

Also I do have Xcode install and I found the path as the one mention abode with the following:

> xcrun --find sourcekit-lsp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp

I'll check the instructions on that file Thanks!

idelfonsog2 commented 3 years ago

oh wait its actually not there!

svanimpe commented 3 years ago

So it's fixed now?

idelfonsog2 commented 3 years ago

Apologize, I am still seeing that I might not have followed the instructions properly. For the LLDB library to specify in VSCode editor for macOS, would it be where it is?

xcrun --find lldb /Applications/Xcode.app/Contents/Developer/usr/bin/lldb

Screen Shot 2020-11-03 at 08 16 06

svanimpe commented 3 years ago

This works for me: /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB

For launch.json and tasks.json I used the same values as on Linux.

idelfonsog2 commented 3 years ago

Thank you @svanimpe that path worked for me and for the launch.json I used the following. In macOS, the executable has a different path and name.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug",
            "program": "${workspaceFolder}/.build/x86_64-apple-macosx/debug/Run",
            "args": [],
            "cwd": "${workspaceFolder}",
            "preLaunchTask": "swift build",
        }
    ]
}
svanimpe commented 3 years ago

In the instructions, the path is ${workspaceFolder}/.build/debug/\<program> where <program> is the name of your executable target. In your case, the executable seems to Run, so ${workspaceFolder}/.build/debug/Run should work.

That .build/debug folder is just a symbolic link to a platform-dependent folder (such as .build/x86_64-apple-macosx/debug), which is why I prefer it.