Search code examples
herokuswift5server-side-swift

Running Swift on Heroku: error while loading shared libraries


I'm trying to deploy a Swift application to Heroku. I'm using Swift 5.0.2 and Heroku Stack 18. This application was previously working with Swift 3.0 and Heroku Stack 16.

I'm not sure what this error is even exactly telling me so I don't quite know where to start to fix it up. I'm using a fork of the Heroku build pack since it didn't even support their own Stack 18. https://github.com/onuniverse/heroku-buildpack-swift

2019-07-19T00:25:55.906961+00:00 heroku[web.1]: State changed from crashed to starting
2019-07-19T00:25:57.109052+00:00 heroku[web.1]: Starting process with command `Unibot --bind 0.0.0.0:58139`
2019-07-19T00:25:58.829639+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-19T00:25:58.761232+00:00 app[web.1]: Unibot: error while loading shared libraries: libicui18nswift.so.61: cannot open shared object file: No such file or directory

Solution

  • Unibot: error while loading shared libraries: libicui18nswift.so.61:
    cannot open shared object file: No such file or directory
    

    The last line of the log suggests that the buildpack you used does not copy all the shared libraries from the Swift toolchain correctly, either because it's looking for predefined library names, or does not take symlinks into account – which were introduced with Swift 5.0.


    I would recommend trying again with the vapor/vapor buildpack (available as source here), which supports Swift 5.0.2 and the heroku-18 stack out of the box.

    Despite its name, it does not contain anything Vapor-specific and works with any Swift project.