GitHub NIO Download Errors?

Is @lukasa 's latest upload is faulty? I'm suddenly getting this error...

pi@satserver:~/SatServer $ swift build
Fetching https://github.com/curuvar/SwiftyGPIO.git from cache
Fetched https://github.com/curuvar/SwiftyGPIO.git (0.91s)
Fetching https://github.com/apple/swift-nio.git from cache
Skipping cache due to an error: Couldn’t fetch updates from remote repositories:
    Fetching origin
    error: object file ./objects/b2/195f797354eddd4c76804654d75b138e1affb1 is empty
    error: object file ./objects/b2/195f797354eddd4c76804654d75b138e1affb1 is empty
    fatal: loose object b2195f797354eddd4c76804654d75b138e1affb1 (stored in ./objects/b2/195f797354eddd4c76804654d75b138e1affb1) is corrupt
    error: Could not fetch origin
Fetched https://github.com/apple/swift-nio.git (14.38s)
Computing version for https://github.com/apple/swift-nio.git
Computed https://github.com/apple/swift-nio.git at 2.38.0 (1.07s)
Creating working copy for https://github.com/apple/swift-nio.git
Working copy of https://github.com/apple/swift-nio.git resolved at 2.38.0
Creating working copy for https://github.com/curuvar/SwiftyGPIO.git
Working copy of https://github.com/curuvar/SwiftyGPIO.git resolved at Safe-I2C
[5/29] Compiling CNIOLinux shim.c

At this point it hangs. A Ctr-C does this...

[5/29] Compiling CNIOLinux shim.cclient_loop: send disconnect: Broken pipe
mike@iMac-2015 ~ % 

I really don't know if it's your end or mine. A quick response will be very much appreciated.

This appears to be an issue in your connection to GitHub: I'm not having any of the same issues. Can you try throwing away your .build directory and rebuilding clean?

Same error after deleting .build. I also did a swift package clean and swift package reset.

Are you using any mirrors?

Not that I'm aware of

// swift-tools-version:5.5

import PackageDescription

let package = Package(
    name: "SatServer",
    platforms: [.macOS(.v12)], // seems odd for Linux, but it allows concurrency
    dependencies: [
        .package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
        // .package(url: "https://github.com/uraimo/SwiftyGPIO.git", from: "1.0.0"),
        // using this fork to get 16 bit I2C working
        .package( url: "https://github.com/curuvar/SwiftyGPIO.git", branch: "Safe-I2C" ),
    ],
    targets: [
        .executableTarget(
            name: "SatServer",
            dependencies: [.product(name: "NIOFoundationCompat", package: "swift-nio"),
                           "SwiftyGPIO"], exclude: ["Resources"]),
    ]
)

Nothing has changed.

Can you try, in a new directory, a straightforward git clone? git clone https://github.com/apple/swift-nio.git

Will do, but I'll loose my git sync.

I'm not proposing you use it generally, I just want to confirm that with SwiftPM out of the picture the clone still functions.

The reason I'm proposing this is that I can't reproduce your issue here:

➜  tmp git clone https://github.com/apple/swift-nio.git
Cloning into 'swift-nio'...
remote: Enumerating objects: 37288, done.
remote: Counting objects: 100% (2947/2947), done.
remote: Compressing objects: 100% (1129/1129), done.
remote: Total 37288 (delta 2081), reused 2418 (delta 1773), pack-reused 34341
Receiving objects: 100% (37288/37288), 46.78 MiB | 378.00 KiB/s, done.
Resolving deltas: 100% (29107/29107), done.
➜  tmp cd swift-nio
➜  swift-nio git:(main) git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (37288/37288), done.
➜  swift-nio git:(main) git rev-parse --short HEAD
b2195f79
pi@satserver:~ $ git clone https://github.com/apple/swift-nio.git
Cloning into 'swift-nio'...
remote: Enumerating objects: 37288, done.
remote: Counting objects: 100% (2931/2931), done.
remote: Compressing objects: 100% (1107/1107), done.
remote: Total 37288 (delta 2070), reused 2420 (delta 1779), pack-reused 34357
Receiving objects: 100% (37288/37288), 46.79 MiB | 16.98 MiB/s, done.
Resolving deltas: 100% (29108/29108), done.
pi@satserver:~ $ 

So I wonder what my problem is. I do know I damaged 6 GPIOs, but that was over a week ago and I've built many times since then, including yesterday. I guess you won't be able to help me any further, so thank you for responding so quickly.

No problem, good luck on debugging!

SwiftPM has a relatively new global cache. The default location for it is ~/.swiftpm which includes a link to ~/Library/Caches/org.swift.swiftpm. You might want to try to delete that cache and try again.

Thank you @dnadobba for your suggestion. My ~/.swiftpm points to /home/pi/.cache/org.swift.swiftpm. The build still hangs at 5/29] Compiling CNIOLinux shim.c.

Next I tried removing ~/.cache and ~/.swiftpm which was not a good idea...

pi@satserver:~/SatServer $ swift build
error: unexpected top-level node
error: unable to load build file
warning: failed to load the cached build description: fatalError
pi@satserver:~/SatServer $ 

I suppose the next step is to re-install Swift and see what else I can screw up.

So I tried...

sudo apt update && sudo apt upgrade
.
.
Preparing to unpack .../14-swiftlang_5.5.3-01-debian-bullseye_arm64.deb ...
Unpacking swiftlang (5.5.3-01-debian-bullseye) over (5.5.2-01-debian-bullseye) ...

No luck here, so...

Sudo apt remove swiftlang
.
.
curl -s https://archive.swiftlang.xyz/install.sh | sudo bash
.
.
sudo apt install swiftlang
.
.
pi@satserver:~/SatServer $ swift build
error: unexpected top-level node
error: unable to load build file
warning: failed to load the cached build description: fatalError
/home/pi/SatServer: error: manifest parse error(s):
<unknown>:0: error: file '/home/pi/.cache/clang/ModuleCache/1TM3MZT8P8JOA/SwiftShims-1KFO504FT44T.pcm' is not a valid precompiled module file
<unknown>:0: error: missing required module 'SwiftShims'
pi@satserver:~/SatServer $ 

I'm asking; do I need to reinstall the entire OS and start again?

Oh, I'm sorry for the tip that destroyed your Swift installation. I don't have any experience with Swift on a raspberry pi but @fabianfett might be able to give you some advice.

Don't worry about that. It was probably when I became more advantageous. Set backs like these are always frustrating, but they do force one to learn a little more.

For what it's worth, a very simple way to "install" swift on linux is to download the right tarball from Swift.org - Download Swift depending on your OS, and then just unzip it :slight_smile: It is ready to use from there, you can move the files to / since the directory structure matches it (/usr etc).

We want to make the installation experience easier but for now that's probably the simplest.

At the time I started this project I tried all the various versions of Ubuntu, but I couldn't figure out which version I should use and if they would work with I2C and 1-Wire. I decided to use the upcoming beta 64bit Bullseye, with the knowledge that it would be 100% compatible with a Raspberry Pi 4B.

But since discovering GPIO has moved into the linux kernel, my view could change - if and when someone writes a Swift binding for this. Python has one, but Python is far more popular than Swift. SWift.org are hoping to change the server World without realising there are far more Raspberrys out there than data centres - something Apple lost interest in many years ago.

I chose Swift because it's new and exciting, but also because SwiftUi on a Mac looks far better than any Python UI I've seen. It's just unfortunate that it's incredibly slow when the screen is bigger that an iPhone.