Vapor 无法部署到 Heroku:我们没有 5.3 的构建说明

Vapor unable to deploy to Heroku: We don't have build instructions for 5.3

我能够将更改提交到我的 Heroku 存储库,但是当我推送它时它显示以下错误:

  remote: Compressing source files... done.
        remote: Building source:
        remote: 
        remote: -----> Swift app detected
        remote: -----> Using Swift 5.3 (from .swift-version file)
        remote: -----> Using built-in clang (Swift 5.3)
        remote: -----> Installing swiftenv
        remote: -----> Installing Swift 5.3
        remote: We don't have build instructions for 5.3.
        remote:  !     Push rejected, failed to compile Swift app.
        remote: 
        remote:  !     Push failed

我使用了以下命令:

$ git add .
$ git commit -am "make it better"
$ git push heroku master

我还将构建包更改为 vapor/vapor:

heroku buildpacks:set vapor/vapor

为什么会出现此错误,我该如何解决?

我什至通过以下命令更改了 swift 版本

 echo "5.1.3" > .swift-version
git add .                    
git commit -m "Done" 

并将其推送到 Heroku 时显示以下错误

package at '/tmp/build_8e6b47bc' is using Swift tools version 5.2.0 but the installed version is 5.1.0

Swift 5.3 doesn't appear to have been released yet,我能找到的唯一 Vapor 构建包还不支持它。

我认为您使用的 this buildpack 在其当前文档中使用 Swift 版本 5.1.3。尝试将 Swift 版本降低到那个版本(通过编辑 .swift-version 文件并提交)并重新部署。

编辑: 您的新错误表明 Swift 工具版本不匹配。我不在 Swift 中编程,但是 it looks like this is defined by a line in your Package.swift file 并且它与您的 Swift 版本有关:

The very first line of a package manifest indicates the Swift tools version required. This specifies the minimum version of Swift that the package supports. The Package description API may also change between Swift versions, so this line ensures Swift will know how to parse your manifest.

尝试改变

// swift-tools-version:5.2

// swift-tools-version:5.1

然后提交并重新部署。

我还建议确保您在本地使用相同版本的 Swift 进行开发,因为您要在服务器上进行开发。