     }
 }
 
+func hasCommand(_ name: String) -> Bool {
+    return system("which \(name) > /dev/null 2>&1") == 0
+}
+
 func curl(url: String, output: String, verbose: Bool = false, followRedirect: Bool = true) throws {
+    guard hasCommand("curl") else {
+        throw Error.commandNotFound
+    }
+
     var cmd = ["curl"]
     if !verbose {
         cmd.append("-s")

enum Error: ErrorProtocol { // Errors pertaining to running commands
    case system(Int32)
    case cancelled
    case terminalSize
}

func run(_ command: String) throws {
    print("### CMD: \(command)")
    let result = system(command)

    if result == 2 {

    do {
        if !exists(path: archive) {
            print("Downloading \(url) ...")
            try download(url: url, output: archive, verbose: true)
        }
    } catch {
        fail("Could not download SPM package")
