vscode-swift icon indicating copy to clipboard operation
vscode-swift copied to clipboard

Could not find /path/to/Package.swift in the workspace

Open JanPolasek opened this issue 6 years ago • 4 comments

I've installed the extensions and provided path to the latest language server built from master, but I'm getting an error every few seconds

[Error - 13:52:49] Request textDocument/completion failed.
  Message: Could not find /path/to/Package.swift in the workspace.
  Code: -32099 

but the Package.swift file is right there. I used a slightly newer version of Swift toolchain than mentioned in prerequisities though, I used 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38) instead of 4.0

JanPolasek avatar Nov 25 '17 13:11 JanPolasek

Running into the same error. My guess (without knowing too much about how vscode-swift works) is that it's blindly asking sourcekit for cursor info for Package.swift, while it is a swift file, it defines the package rather than being part of the package.

strangemonad avatar May 23 '18 18:05 strangemonad

I think you are right @strangemonad. Now how to solve this?

I think the best way is to make the language-server smarter. Though in what way is not immediately clear to me.

Possibly just disable the extension for Package*.swift files in the root of the workspace?

RLovelett avatar May 23 '18 20:05 RLovelett

Without digging in more, that might be too aggressive (from what I know so far of SourceKit). I think you still want syntax parsing / highlighting of Package.swift (as it is a swift file) but you don't want to query the SPM-aware "oracle" with cursor position since it's not part of the package (per SPM's view of the world). Yet you still want basic completion, documentation quick-view and pop-ups showing type signatures of the Package related types.

Basically, I think the fix is a larger one. You almost need some sense of a parallel instance of sourcekit which loads Package.swift on its own (assuming it depends on Swift and SPM only) and then the other sourckit root configured based on the package dependencies. Both of these would require work to make the language server "SPM-aware".

I don't want to commit my juuust yet because I'm not sure how much I'll have but I'm tempted to dig into this a bit more

strangemonad avatar May 23 '18 23:05 strangemonad

FWIW not even Xcode tries to give you completion inside of Package.swift :rofl:

Basically, I think the fix is a larger one. You almost need some sense of a parallel instance of sourcekit which loads Package.swift on its own (assuming it depends on Swift and SPM only) and then the other sourckit root configured based on the package dependencies.

That is an intriguing solution. :thinking:

RLovelett avatar Jun 01 '18 21:06 RLovelett