Installing GEOS on Heroku

867 views Asked by At

I'm trying to deploy a Rails app (ruby 2.3.0, rails 4.2.6) to Heroku that uses the RGeo gem, but I'm having no luck installing the underlying GEOS library upon which the RGeo gem relies (See https://github.com/rgeo/rgeo#dependencies).

According to Heroku's own instructions, this should be possible by using the heroku-geo-buildpack, but it's not working.

ADD BUILDPACK TO APP:

$ heroku buildpacks:set https://github.com/cyberdelia/heroku-geo-buildpack.git
$ heroku buildpacks:add heroku/ruby

BUILD PROCESS LOOKS GOOD:

remote: Building source:
remote: 
remote: -----> geos/gdal/proj app detected
remote:        Using geos version: 3.4.2
remote:        Using gdal version: 1.11.1
remote:        Using proj version: 4.8.0_1
remote: -----> Vendoring geo libraries done
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.0

TEST DEPENDENCY:

>>> require 'rgeo'
=> false
>>> RGeo::CoordSys::Proj4.supported?
=> true
>>> RGeo::Geos.supported?
=> false
2

There are 2 answers

0
Yarin On BEST ANSWER

While the previously accepted answer worked at the time, those buildpacks have since been deprecated.

The current solution seems to be to use the newer heroku-geo-buildpack.

Other options can be found here: rgeoEnable-GEOS-and-Proj4-on-Heroku.md at main ยท rgeorgeo - GitHub

1
mlabarca On

There seems to be problems getting that specific geos buildpack on heroku, mainly because of the build arguments for geos. For full details you can check this pull request to the buildpack where a lot of this is discussed. The solution using a fork of the webpack is described in detail in this blog post.

STEP 1: Create this .vendor_urls file in the root of your project:

https://s3.amazonaws.com/diowa-buildpacks/geos-3.5.0-heroku.tar.gz
https://s3.amazonaws.com/diowa-buildpacks/proj-4.9.1-heroku.tar.gz

Add this file to git and make sure it ends with a newline.

STEP 2: Set up your Heroku configuration:

heroku buildpacks:set https://github.com/diowa/heroku-buildpack-rgeo-prep.git
heroku buildpacks:add https://github.com/peterkeen/heroku-buildpack-vendorbinaries.git
heroku buildpacks:add heroku/ruby
heroku config:set LD_LIBRARY_PATH=/app/lib

(SEE https://github.com/diowa/heroku-buildpack-rgeo-prep#setup)

Finally, note that if you have already installed rgeo, you need to recompile the gem. You can do that by using the heroku repo plugin, running heroku repo:purge_cache -a appname and deploying again.

(SEE http://www.diowa.com/blog/heroku/2016/02/26/using-rgeo-with-geos-on-heroku#deploy)