ruby-gnome: Unable to install poppler on Heroku

I’ve been trying to get poppler to work on Heroku for a couple of days now with no success. Here are the things I’ve tried:

  • Use https://github.com/heroku/heroku-buildpack-activestorage-preview buildpack which includes poppler for Rails 5.2. This fails gobject-introspection 3.3.0 install with the following error:
remote:        checking for gobject-introspection-1.0... no
remote:        installing 'libgirepository1.0-dev' native package... require super user
remote:        privilege
remote:        'libgirepository1.0-dev' native package is required.
remote:        Run the following command as super user to install required native package:
remote:          # apt install -V -y libgirepository1.0-dev
  • Use https://github.com/iwasaki-d/heroku-buildpack-ruby-poppler buildpack, which builds version 0.59.0. Also tried https://github.com/Captive-Studio/heroku-buildpack-ruby-poppler which builds version 0.69.0. On heroku-18 stack, they fail with:
remote: Makefile:1696: recipe for target 'stage1scan.c' failed
remote: make[2]: *** [stage1scan.c] Segmentation fault
remote: make[2]: Leaving directory '/app/tmp/buildpacks/da268f3348644ae2c7bfbcddcbb4aaccb8f5982dab5dc1c6bd70c93922e568a6fa585adc1914eb5213c3c2394864ac20722e8909fde8fe19b958d89456c001b4/tmp/flex-2.6.4/src'
remote: Makefile:546: recipe for target 'all' failed
remote: make[1]: *** [all] Error 2
remote: make[1]: Leaving directory '/app/tmp/buildpacks/da268f3348644ae2c7bfbcddcbb4aaccb8f5982dab5dc1c6bd70c93922e568a6fa585adc1914eb5213c3c2394864ac20722e8909fde8fe19b958d89456c001b4/tmp/flex-2.6.4/src'
remote: Makefile:533: recipe for target 'all-recursive' failed

This seems to be more of an issue with flex and heroku-18. I tried again on heroku-16 stack and finally got a successful build, but it fails when detecting Rake tasks with the following error:

GObjectIntrospection::RepositoryError::TypelibNotFound: Typelib file for namespace 'Poppler' (any version) not found

I tried to fix that by setting GI_TYPELIB_PATH=/app/.apt/usr/lib/x86_64-linux-gnu/girepository-1.0 but that didn’t help.

  • Use heroku-community/apt buildpack with the following libraries:
libgirepository-1.0-1
libgirepository1.0-dev
libpoppler-glib-dev

This failed with the same Poppler typelib error above. GI_TYPELIB_PATH did not help.

I also tried poppler 3.1.9 but got this error:

LoadError: cannot load such file -- cairo-gobject

I’m at a total loss…how do I get Poppler working on Heroku? These tests are all with a brand new Rails app and new Heroku app. My guess is that I’m closest to success when I’m getting the typelib error, but I’m not sure how to fix that.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 54 (25 by maintainers)

Commits related to this issue

Most upvoted comments

If anyone is facing the same issue, here’s what worked for me (Heroku stack 20):

Removed poppler from Gemfile

Aptfile:

gir1.2-poppler-0.18
gir1.2-rsvg-2.0
gir1.2-gdkpixbuf-2.0
gir1.2-freedesktop
gir1.2-glib-2.0
libgirepository-1.0-1
libgirepository1.0-dev
libpoppler-dev
libpoppler-glib-dev
libcairo-gobject2
poppler-utils

Heroku buildpacks

1. https://github.com/brandoncc/heroku-buildpack-vips
2. heroku-community/apt
3. heroku/ruby

thanks for sharing the update @michaelschmitz I have the poppler gem too, hmmm gonna need a little more time to find out the cause here… will share if any

Good to know. 😃

@kou You solved it. It works now - many thanks!

In case other people have the same issue and want to use Poppler on the Heroku-18 stack, this is my current setup:

Heroku buildpacks:

remote: -----> Using buildpacks:
remote:        1. https://github.com/michaelschmitz/heroku-buildpack-apt
remote:        2. heroku/ruby

Gemfile (Edit: added after @shanqyeet’s message below for completeness):

gem 'poppler'
gem 'mini_magick' 

boot.rb:

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.

Aptfile:

gir1.2-freedesktop
gir1.2-glib-2.0
libgirepository-1.0-1
libgirepository1.0-dev
libpoppler-glib-dev
libcairo-gobject2
poppler
poppler-utils

Could you also add gir1.2-glib-2.0 to your Aptfile?

An empty GObjectIntrospection::Repository.search_path is no problem because it’s initialized lazy. It’s not initialized without prepend_search_path, GObjectIntrospection.load and so on.

Thanks.

  • We don’t need GObjectIntrospection::Repository.prepend_search_path('/app/.apt/usr/lib/x86_64-linux-gnu/girepository-1.0')
  • We need to add gir1.2-freedesktop to Aptfile.
  • We need to add gem "poppler" to Gemfile and remove gem "gobject-introspection" from Gemfile and GObjectIntrospection.load("Poppler") from boot.rb.

Could you add Find.find("/app") {|path| puts(path)} to your boot.rb?

Could you try the following?

#The below is required for poppler pdf previews
puts ENV['GI_TYPELIB_PATH']
require 'gobject-introspection'
GObjectIntrospection::Repository.prepend_search_path('/app/.apt/usr/lib/x86_64-linux-gnu/girepository-1.0')
p GObjectIntrospection::Repository.search_path
require "find"
GObjectIntrospection::Repository.search_path.each do |search_path|
  p [search_path, File.exist?(search_path)]
  if File.exist?(search_path)
    Find.find(search_path) {|path| puts(path)}
  end
end
GObjectIntrospection.load('Poppler')

Thanks. Can you use kou@cozmixng.org as my Heroku account?