0

当我尝试在终端中运行迁移时,vapor toolbox -18.0.0 出现错误。

我在 configure.swift中的代码

public func configure(_ app: Application) throws {
    // uncomment to serve files from /Public folder
    // app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
    app.databases.use(.postgres(hostname: "localhost", username: "postgres", password: "", database: "mydatabase"), as: .psql)
    app.migrations.add(CreateMovie())
    // register routes
    try routes(app)
}

我的 迁移代码

struct CreateMovie: Migration {
    
    func prepare(on database: Database) -> EventLoopFuture<Void> {
        database.schema("movies") //tablename
        .id()
            .field("title", .string) //column name
        .create()
    }
    
    //undo
    func revert(on database: Database) -> EventLoopFuture<Void> {
        database.schema("movies").delete()
    } 
}

以下是输出。

HomeMBP:vaporize-me username$ vapor run migrate

Updating https://github.com/vapor/fluent-kit.git

Updating https://github.com/apple/swift-metrics.git

Updating https://github.com/apple/swift-nio-extras.git

Updating https://github.com/vapor/postgres-nio.git

Updating https://github.com/vapor/fluent.git

Updating https://github.com/swift-server/async-http-client.git

Updating https://github.com/vapor/async-kit.git

Updating https://github.com/apple/swift-log.git

Updating https://github.com/vapor/websocket-kit.git

Updating https://github.com/swift-server/swift-backtrace.git

Updating https://github.com/vapor/fluent-postgres-driver.git

Updating https://github.com/vapor/sql-kit.git

Updating https://github.com/apple/swift-crypto.git

Updating https://github.com/apple/swift-nio.git

Updating https://github.com/vapor/postgres-kit.git

Updating https://github.com/vapor/routing-kit.git

Updating https://github.com/vapor/console-kit.git

Updating https://github.com/vapor/vapor.git

Updating https://github.com/apple/swift-nio-http2.git

Updating https://github.com/apple/swift-nio-ssl.git

error: terminated(128): PWD=/Users/username/Learning/vaporize-me XPC_SERVICE_NAME=0 __CF_USER_TEXT_ENCODING=0x1F7:0x0:0x0 LC_CTYPE=UTF-8 GIT_SSH_COMMAND=ssh -oBatchMode=yes SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk SHLVL=1 _=/usr/local/bin/vapor TERM_PROGRAM=Apple_Terminal LIBRARY_PATH=/usr/local/lib PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin HOME=/Users/username SECURITYSESSIONID=186a6 XPC_FLAGS=0x0 LOGNAME=username TMPDIR=/var/folders/pw/nx75wvr9177bygn9s6gr9gl80000gq/T/ LaunchInstanceID=8E492B00-D02E-4F8C-8622-E24E55DB8162 TERM=xterm-256color USER=username OLDPWD=/Users/username TERM_SESSION_ID=3F21BA5B-F0B0-49FF-9E0E-66445430473A GIT_TERMINAL_PROMPT=0 CPATH=/usr/local/include SHELL=/bin/bash SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.wN5DP9iUWU/Listeners TERM_PROGRAM_VERSION=433 git -C /Users/username/Learning/vaporize-me/.build/repositories/vapor-2c13b66e remote update -p output:

fatal: cannot change to '/Users/username/Learning/vaporize-me/.build/repositories/vapor-2c13b66e': No such file or directory



Fatal error: result 1: file /private/tmp/vapor-20200707-2429-1rpgdhn/toolbox-18.0.0/Sources/VaporToolbox/exec.swift, line 55

Illegal instruction: 4

我自己做了一些研究,但找不到任何解决方案。

请帮忙!!!!

4

1 回答 1

1

看起来您的Package.resolved文件无效。您可以通过在构建项目之前运行来解决此问题swift package update,或者只是删除您的Package.resolved文件。

于 2020-07-22T13:03:27.080 回答