#swift build Error for Vapor & Leaf: the package manifest at … cannot be accessed

1 messages · Page 1 of 1 (latest)

arctic wren
#

Hello,

I am trying to deploy my Vapor project to AWS. I am following the instructions in Chapter 34 of the Kodeco book.

I am currently at the “Setting up your application” step. I believe all the previous steps have been successfully completed.

I cloned by project to the AWS instance running Ubuntu 20.04, changed directories then tried to run the build command but got an error:

Command
swift build -c release --enable-test-discovery

Output
error: 'leaf': the package manifest at '/home/ubuntu/kevinfrenchcom/website/.build/checkouts/leaf/Package.swift' cannot be accessed (/home/ubuntu/kevinfrenchcom/website/.build/checkouts/leaf/Package.swift doesn't exist in file system)
error: 'vapor': the package manifest at '/home/ubuntu/kevinfrenchcom/website/.build/checkouts/vapor/Package.swift' cannot be accessed (/home/ubuntu/kevinfrenchcom/website/.build/checkouts/vapor/Package.swift doesn't exist in file system)
error: 'leaf': the package manifest at '/home/ubuntu/kevinfrenchcom/website/.build/checkouts/leaf/Package.swift' cannot be accessed (/home/ubuntu/kevinfrenchcom/website/.build/checkouts/leaf/Package.swift doesn't exist in file system)
error: 'vapor': the package manifest at '/home/ubuntu/kevinfrenchcom/website/.build/checkouts/vapor/Package.swift' cannot be accessed (/home/ubuntu/kevinfrenchcom/website/.build/checkouts/vapor/Package.swift doesn't exist in file system)

When I run ls in the same directory I get the following output:

Dockerfile Package.resolved Package.swift Public Resources Sources Tests docker-compose.yml fly.toml

I am able to run the project on my local machine (2023 M2 Mac Mini).

Running just “swift build” on the AWS instance produces the same error output as mentioned above.

Can someone help me with this error?

Thank you,

Kevin

#

Package.swift

#

// swift-tools-version:5.9
import PackageDescription

let package = Package(
    name: "website",
    platforms: [
       .macOS(.v13)
    ],
    dependencies: [
        // 💧 A server-side Swift web framework.
        .package(url: "https://github.com/vapor/vapor.git", from: "4.83.1"),
        // 🍃 An expressive, performant, and extensible templating language built for Swift.
        .package(url: "https://github.com/vapor/leaf.git", from: "4.2.4")
//        .package(url: "https://github.com/joannis/SMTPKitten.git", from: "0.2.0")
    ],
    targets: [
        .executableTarget(
            name: "App",
            dependencies: [
                .product(name: "Leaf", package: "leaf"),
                .product(name: "Vapor", package: "vapor")
//                .product(name: "SMTPKitten", package: "SMTPKitten")
            ]
        ),
        .testTarget(name: "AppTests", dependencies: [
            .target(name: "App"),
            .product(name: "XCTVapor", package: "vapor"),

// Workaround for https://github.com/apple/swift-package-manager/issues/6940
            .product(name: "Vapor", package: "vapor"),
            .product(name: "Leaf", package: "leaf")
        ])
    ]
)

GitHub

I have a (somewhat experimental) Swift Package ApproximateEquality that exposes a Swift Macro. Everything seems to work fine and the macro works as intended. The macro unit tests all run fine. Yay ...

tawdry crest
#

How did you get the code onto the EC2 box?

#

It looks like you've copied over the build directory

#

Try doing rm -rf .build and try again

arctic wren
#

I cloned the repo from GitHub.

tawdry crest
#

Did a clean help?

arctic wren
#

I ran rm -rf .build, then the release build command again and got passed that step. Thank you, @tawdry crest 🙏

glacial mapleBOT
arctic wren
#

@tawdry crest I followed the steps to set up the app as a system service but keep getting this error

#

● portfolio.service - "portfolio"
Loaded: loaded (/etc/systemd/system/portfolio.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2024-02-22 18:31:32 UTC; 21s ago
Main PID: 45773 (code=exited, status=203/EXEC)

Feb 22 18:31:31 ip-172-31-5-60 systemd[45773]: portfolio.service: Failed at step EXEC spawning /home/ubuntu/kevinfrenchcom/website/.build/release/Run: No such file or directory
Feb 22 18:31:31 ip-172-31-5-60 systemd[1]: portfolio.service: Main process exited, code=exited, status=203/EXEC
Feb 22 18:31:31 ip-172-31-5-60 systemd[1]: portfolio.service: Failed with result 'exit-code'.
Feb 22 18:31:32 ip-172-31-5-60 systemd[1]: portfolio.service: Scheduled restart job, restart counter is at 5.
Feb 22 18:31:32 ip-172-31-5-60 systemd[1]: Stopped "portfolio".
Feb 22 18:31:32 ip-172-31-5-60 systemd[1]: portfolio.service: Start request repeated too quickly.
Feb 22 18:31:32 ip-172-31-5-60 systemd[1]: portfolio.service: Failed with result 'exit-code'.
Feb 22 18:31:32 ip-172-31-5-60 systemd[1]: Failed to start "portfolio".

#

It looks like an issue with the build step. I tried to rerun it and am now getting a bunch of errors like these

#

error: 'swift-nio-extras': invalid access to /tmp/home_ubuntu_kevinfrenchcom_website.build_workspace-state.json.lock
Creating working copy for https://github.com/vapor/vapor.git
error: 'vapor': invalid access to /tmp/home_ubuntu_kevinfrenchcom_website.build_workspace-state.json.lock
Creating working copy for https://github.com/apple/swift-http-types
error: 'swift-http-types': invalid access to /tmp/home_ubuntu_kevinfrenchcom_website.build_workspace-state.json.lock
Creating working copy for https://github.com/swift-server/async-http-client.git

GitHub

💧 A server-side Swift HTTP web framework. Contribute to vapor/vapor development by creating an account on GitHub.

GitHub

Version-independent HTTP currency types for Swift. Contribute to apple/swift-http-types development by creating an account on GitHub.

GitHub

HTTP client library built on SwiftNIO. Contribute to swift-server/async-http-client development by creating an account on GitHub.

#

I made sure to run the commands to handle a potential system memory issue that are listed in the book beforehand

tawdry crest
#

@arctic wren are you on the new template?

#

If so Run should be App

#

Those errors are weird, normally solved by a clean

arctic wren
#

@tawdry crest I’m not sure what you mean by “new template”. I am also not sure how I should do the clean. I did a clean in Xcode and pushed that to GitHub then pulled it on the aws instance, ran the full swift build release command and got the same errors. I then tried “swift package clean” on the AWS instance on got the same errors again.

tawdry crest
#

@arctic wren just to check you're not checking in the .build directory to Git?

arctic wren
#

@tawdry crest I have been committing it. I’ve been making sure to delete it before doing any of the build operations on the AWS machine though. I’ll add it the my gitignore and try everything again 👍👍

arctic wren
#

@tawdry crest Good morning Tim. I appreciate your help with this. I stopped checking in the .build directory and tried everything again and got the same errors. I tried also not checking in Package.resolved and again saw the same errors. Any other fixes you can think of for me to try?

tawdry crest
#

Do you have the code anywhere on GH to try to reproduce?

arctic wren
#

The script got the full swift build release command to work. Thanks a lot, @tawdry crest! 🙏

glacial mapleBOT
tawdry crest
#

Great!