2

I wrote a Slackbot with SlackKit and Swift 4.0. I followed a very simple and easy to understand tutorial from Peter Zignego

He deployed his Bot at Heroku

So first issue that appears was that I use a array extension which gives me a random item from a given collection:

extension Array {
    /// Picks `n` random elements (partial Fisher-Yates shuffle approach)
    subscript (randomPick n: Int) -> [Element] {
      var copy = self
      for i in stride(from: count - 1, to: count - n - 1, by: -1) {
          copy.swapAt(i, Int(arc4random_uniform(UInt32(i + 1))))
      }
      return Array(copy.suffix(n))
    }
}

With this code I´ve got no build issues and I want to push my code to Heroku but while it runs throw the deployment an error occurs:

error: use of unresolved identifier 'arc4random_uniform'

After searching I found a Swift reported Bug and changed my code to:

extension Array {
    /// Picks `n` random elements (partial Fisher-Yates shuffle approach)
    subscript (randomPick n: Int) -> [Element] {
        var copy = self
        for i in stride(from: count - 1, to: count - n - 1, by: -1) {
            #if os(Linux)
                copy.swapAt(i, Int(random() % (i + 1)))
            #else
                copy.swapAt(i, Int(arc4random_uniform(UInt32(i + 1))))
            #endif

         }
         return Array(copy.suffix(n))
    }
}

Now my code pushed and deployed on Heroku successfully.

But when I want to start the Bot in my Slack Channel like:

rf24-dev-mac-1:support-dialer konstantin$ heroku run:detached slackbot
Running slackbot on ⬢ support-dialer... done, run.1246 (Free)
Run heroku logs --app support-dialer --dyno run.1246 to view the output.

and run the output command I get this:

2017-09-25T13:37:27.762135+00:00 heroku[run.1246]: Starting process with command `.build/release/support-dialer`
2017-09-25T13:37:28.335452+00:00 heroku[run.1246]: State changed from starting to up
2017-09-25T13:37:29.842073+00:00 heroku[run.1246]: Process exited with status 127
2017-09-25T13:37:29.779834+00:00 app[run.1246]: .build/release/support-dialer: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
2017-09-25T13:37:29.856440+00:00 heroku[run.1246]: State changed from up to complete

So I have no idea what I can do to fix this because it does not start the Slackbot and when I clicked the deploy link at Heroku it also says there is an error.

0 Answers0