RGeo::Geos.supported? shows as false even with -dev packages and symlink in place

601 views Asked by At

Trying to get the rgeo gem to recognise geos on an ubuntu 16.04 system.

I have the following packages installed:-

libgeos-dev, libgeos++-dev and libgeos-3.7.1

geos-config --version
3.7.1

I have a symlink in /usr/lib which points to the location of the version specific version in

lrwxrwxrwx  1 root root   42 Oct 21 18:05 libgeos.so -> /usr/lib/x86_64-linux-gnu/libgeos-3.7.1.so

Have run the following commands

gem uninstall rgeo
gem install rgeo -- --with-geos-dir=/usr/lib

However when I run the following it fails

RAILS_ENV=staging bundle exec irb
require 'rgeo'
RGeo::Geos.supported?
 => false

What am I doing wrong? Have searched the various posts about this which has led me to install the -dev package and create the symlink, but still it doesnt work.

Have also added /usr/lib to /etc/ld.so.conf.d/ and run ldconfig but without success.

Update

RAILS_ENV=staging bundle exec irb
2.5.0 :001 > require 'rgeo'
=> true
2.5.0 :002 > RGeo::Geos.supported?
=> true
2.5.0 :003 >

shows it working, but

Loading staging environment (Rails 5.2.0)
2.5.0 :001 > require 'rgeo'
=> false
2.5.0 :002 > RGeo::Geos.supported?
=> false

fails

and the app still shows

RGeo::Error::RGeoError (GEOS is not available, but is required for correct interpretation of polygons in shapefiles.)
2

There are 2 answers

1
Andrew Albert On

To fix that on CircleCi I needed to run these commands on ubuntu machine, then re-install rgeo gem

sudo apt update
sudo apt install libgeos++-dev libgeos-3.8.0 libgeos-c1v5 libgeos-dev libgeos-doc
gem unintsall rgeo
gem install rgeo
0
RokasPo On

spring stop and restarting rails console fixed it for me.