3

I've upgraded to rails 5.2 and am implementing ActiveStorage. ActiveStorage uses mutool for PDF processing. I have successfully installed mutool locally using homebrew.

mutool is a bit confusing.  

rails docs claim to require "mutool", 
homebrew installs "mupdf-tools", 
and heroku wants "mupdf".

I have successfully installed apt and mupdf on heroku following these steps:

- add a new Aptfile to the root of my application with only "mupdf" listed
- commit and push the Aptfile
- THEN run heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
- push again so heroku will finish installing apt and mupdf

mupdf builds successful during the push

heroku buildpacks now returns    
1. https://github.com/heroku/heroku-buildpack-apt
2. heroku/ruby

If I refresh a page calling for a variant on a PDF, the image fails to process and the job kicks back the following error:

  Errno::ENOENT: No such file or directory - mutool

It seems mutool and mupdf are synonomous...so, I tried swapping out mutool for mupdf in my Aptfile...that failed to build from "...not found'.

Anyone know what action I need to take?

PS: This is part of implementing rails 5.2 using ActiveStorage.

UPDATE

I added mupdf-tools to Aptfile and that seems to fix the "no such file or directory" error. I don't know for sure because a new errors surfaces

MiniMagick::Invalid: `identify /tmp/mini_magick20180105-4-pvub9r` failed with error: identify.im6: no decode delegate for this image format `/tmp/mini_magick20180105-4-pvub9r' @ error/constitute.c/ReadImage/544.

MiniMagick::Error: `identify -format %m %w %h %b /tmp/ActiveStorage20180105-4-1f46tem[0]` failed with error: identify.im6: no decode delegate for this image format `/tmp/ActiveStorage20180105-4-1f46tem' @ error/constitute.c/ReadImage/544.
hellion
  • 4,602
  • 6
  • 38
  • 77

2 Answers2

4

Heroku recommends Poppler as an alternative to MuPDF for licensing reasons (MuPDF has a commercial license).

They created a buildpack for Active Storage Previews that covers PDFs as well as Video files.

cseelus
  • 1,447
  • 1
  • 20
  • 31
2

I know this is a bit old, but if you're still having this issue I was able to resolve this by updating the version of mupdf-tools to at least 1.8.

To do this with Heroku, you'll want to link directly to the latest release.

Add heroku-buildpack-apt, and then add a custom Aptfile. Note that you'll need to add the Aptfile first in order for the buildpack to work.

Here is what my Aptfile looks like:

:repo:deb http://archive.ubuntu.com/ubuntu artful main universe
imagemagick
ffmpeg
mupdf-tools

To test that you have the right version, you can use heroku ps:exec to test. Run mutool -v and you should be on version 1.11.

Mike Wilson
  • 692
  • 6
  • 12
  • Thanks @mike-wilson. It is important to note that mutool does not have a public license. This seemed to be an oversight when initially added to rails. Rails 5.2 will not ship with mutool, instead they have swapped it for popper....which is GNU. I'm running the latest commit of 5.2.0.rc1 and popper handles PDF previewing just fine. – hellion Mar 17 '18 at 06:43