Rgeo-proj4 & postgis config for CircleCi 2.0

ruby
postgresql
2.0

#1

Hi!

I’m trying to migrate a rails app that uses postgis and rgeo to CirlceCi 2.0. I’m using the following config

# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.5.1-node-browsers
        environment:
          RAILS_ENV: test
          PGHOST: 127.0.0.1
          PGUSER: root
      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      - image: circleci/postgres:10.3-postgis-ram
        environment:
          POSTGRES_USER: root
          POSTGRES_DB: circle-test_test

    working_directory: ~/repo

I’m getting the following errors because the rgeo-proj4 gem isn’t being setup correctly.

Failure/Error: MERC_FACTORY = RGeo::Geographic.projected_factory(buffer_resolution: 8, projection_proj4: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs", projection_srid: 3857)

RGeo::Error::UnsupportedOperation:
  Coordinate system 'proj4' is not supported.

The rgeo-proj4 depends on native extensions (proj4) that are installed as part of the postgis image as far as I know. Perhaps the the gems are being installed before the postgis environment has been set up. I’m fairly clueless at this stuff but I tried reversing the order of the images but that definitely didn’t work

It would be pretty standard to use rgeo-proj4 when using postgis with ruby so I’m surprised there are issues. I must be doing something strange. If anyone can help I would be very grateful

Conor


#2

Hello,
If you need any custom dependencies in your database image what I would suggest doing is creating a custom Docker image using ours as the base image.

We have a short and easy video tutorial on how to do that in our docs:

https://circleci.com/docs/2.0/custom-images/#how-to-customize-docker-images-for-circleci-20-video-tutorial

You can add the install step for the required dependencies for your database and use this image instead.


#3

I noticed that I’m not the only user that has run into this issue

I’m just wondering what the best way to alter my config file to ensure the proj4 library needed by the rgeos is installed.


#4

I have since update my config file and I have partial solution for the proj4 issue. I have added a step that installs the proj4 library - run: sudo apt-get install libproj-dev. However, although this solves the issues it doesn’t seem to play well with the dependency caching functionality. The tests pass if I select ‘rebuild with cache’ but not if the cache is used. I could remove the dependency
caching logic but I was just wondering if there is a better way of fixing this issue? Any help would be greatly appreciated

steps:
      - checkout
      - run: sudo apt-get install libproj-dev
      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "Gemfile.lock" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run:
          name: install dependencies
          command: |
            bundle install --jobs=4 --retry=3 --path vendor/bundle

      - save_cache:
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      # Database setup
      - run: bundle exec rake db:create
      - run: bundle exec rake db:schema:load

#5

It sounds like you may be restoring on old cache to your project with new dependencies. Could you try iterating v1 to v2 in your cache key and triggering a new build with a commit? This should regenerate the cache.


#6

Hi Cormac, That did the trick, Thanks a million for your help


#7

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.