Using RGeo with GEOS on Heroku
Posted by Geremia Taglialatela on 26 February 2016
We had some struggles making RGeo work on Heroku with GEOS extension. Web lacks of updated information about this topic, the purpose of this post is to collect existing information and update them.
Update! August, 1st 2017
Please take a look at the new article: Use RGeo with GEOS on Heroku via apt-get
Update! July, 1st 2016
BUILDPACK_URL was deprecated, so here it is a new approach.
1. Compile libraries (optional)
Take a look at Compile libraries on Heroku with Vesuvius and
2. Set up multiple buildpacks
We need to set
LD_LIBRARY_PATH config variable to
/app/lib and use the following buildpacks:
Overwrites Heroku’s default .bundle/config to set BUNDLE_BUILD__RGEO to Heroku’s build directory
Allows us to vendor binaries into our project
The official Heroku Buildpack for Ruby, Rack, and Rails apps
We have a couple of way of achieving this:
Method 1: Using app.json
You need the following entries:
Method 2: Using the console
3. Provide URLs of vendor libraries
Vendor Binaries buildpack expects a
.vendor_urls file in the root of the repository containing publicly accessible URLs to the libraries compiled at step 1.
Here it is a working example:
Add this file to git and make sure it ends with a newline.
Deploy to Heroku. Please note that if you have already installed rgeo, you need to recompile the gem.
Check the deploy log:
You can force recompiling in two ways:
- Downgrade to a previous version of rgeo (0.5.3), deploy, rollback, deploy again;
- Using the heroku repo plugin, running
heroku repo:purge_cache -a appnameand deploying again (recommended).
You can check that everything is working by running
heroku run console:
This guide could also be applied to proj.4. Take a look at our rgeo-prep buildpack if you need both libraries.