swift - 在 Ubuntu WSL 上构建 sourcekit-lsp 时出错

标签 swift ubuntu windows-subsystem-for-linux sourcekit

我正在尝试在我的 Ubuntu WSl 上构建 sourcekit-lsp。安装成功 swift swift-5.2.5-RELEASE-ubuntu20.04

amal@DESKTOP-CJJEUS7:~/sourcekit-lsp$swift --version
Swift version 5.2.5 (swift-5.2.5-RELEASE)
Target: x86_64-unknown-linux-gnu
并克隆sourcekit-lst来自 master 分支,安装了两个 sudo apt install libsqlite3-dev libncurses5-dev , 跟随 documentation 的每一步, 但是在构建时我得到了这个错误。swift build -Xcxx -I/home/amal/swift-5.2.5-RELEASE-ubuntu20.04/usr/lib/swift -Xcxx -I/home/amal/swift-5.2.5-RELEASE-ubuntu20.04/usr/lib/swift/Block
/home/amal/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/ManifestLoader.swift:530:55: error: type 'JSONEncoder.OutputFormatting' has no member 'withoutEscapingSlashes' encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
/home/amal/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/ManifestLoader.swift:530:55: error: type 'JSONEncoder.OutputFormatting' has no member 'withoutEscapingSlashes' encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
/home/amal/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/ManifestLoader.swift:530:55: error: type 'JSONEncoder.OutputFormatting' has no member 'withoutEscapingSlashes' encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
[137/214] Compiling Statistic.cpp
知道我做错了什么吗?请帮忙。

最佳答案

当它像这样默默地失败时,通常是因为您缺少一些依赖项。
确保安装所有

sudo apt-get install curl clang libicu-dev git libatomic1 libxml2 \
libcurl4 zlib1g-dev libbsd0 tzdata libssl-dev libsqlite3-dev \
libblocksruntime-dev libncurses5-dev libicu-dev libblocksruntime-dev \
libpthread-workqueue-dev -y
然后我仍然在 main 上失败了sourcekit-lsp的分公司有错误
/home/rock64/Software/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/ManifestLoader.swift:548:55: error: type 'JSONEncoder.OutputFormatting' has no member 'withoutEscapingSlashes'
            encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
                                                     ~^~~~~~~~~~~~~~~~~~~~~~
但更改为本地克隆的swift-package-manager帮助编译。我刚刚更改了 Package.swift 末尾的依赖项文件在 sourcekit-lsp像这样获取本地 spm 的项目
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
  // Building standalone.
  package.dependencies += [
    .package(name: "IndexStoreDB", url: "https://github.com/apple/indexstore-db.git", .branch("main")),
    //.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("main")),
    .package(name: "SwiftPM", path: "/home/rock64/Software/swift-package-manager"),
    .package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("main")),
    .package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.3.0")),
  ]
} else {
⋮
并删除了失败的枚举案例 encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]在文件中swift-package-manager/Sourcswift-package-manager/Sources/PackageLoading/ManifestLoader.swiftes/PackageLoading/ManifestLoader.swift所以现在只是 encoder.outputFormatting = [.sortedKeys]只要确保你使用你的路径并且不要忘记在本地克隆的 swift-package-manager 中提交更改
这应该可以帮助您完成编译阶段。我可以确认服务器在 vim 和 vscode 中运行良好,但由于枚举编辑可能存在一些隐藏故障。我稍后会进一步调查

关于swift - 在 Ubuntu WSL 上构建 sourcekit-lsp 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63604002/

相关文章:

swift - 动态更新 More ViewController 表中的选项卡栏项目

javascript - 当 shell 具有同名程序时如何运行全局 npm 可执行文件

php - fastcgi:php未与mysql连接?

python - Jupyterlab : Directory keeps redirecting to where jupyter_notebook_config. py 是

ios - UITableViewCell 内的 UIView 转换不起作用

swift - 测试内存中 Realm 迁移

swift - 使用 Alamofire 的同步请求

r - Shiny 服务器: leafet doesn't display viridis colors in legend

c++ - Windows 进程和 WSL Linux 进程之间的共享内存

windows - Intellij Windows 终端作为终端(在 IDE 中)