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.
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.
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.
Related
When upgrading from rails 6 to rails 7, and running some ActiveStorage methods locally, I see:
Could not open library 'vips.42': dlopen(vips.42, 0x0005): tried: 'vips.42' (no such file), '/usr/local/lib/vips.42' (no such file), '/usr/lib/vips.42' (no such file), '/Users/st/rails/myapp/vips.42' (no such file), '/usr/local/lib/vips.42' (no such file), '/usr/lib/vips.42' (no such file). (LoadError)
Could not open library 'libvips.42.dylib': dlopen(libvips.42.dylib, 0x0005): tried: 'libvips.42.dylib' (no such file), '/usr/local/lib/libvips.42.dylib' (no such file), '/usr/lib/libvips.42.dylib' (no such file), '/Users/st/rails/myapp/libvips.42.dylib' (no such file), '/usr/local/lib/libvips.42.dylib' (no such file), '/usr/lib/libvips.42.dylib' (no such file)
There are a number of GitHub issues with similar: (e.g. here).
I am not sure if I need to install the ruby-vips gem or if there's something problematic with my OS / shared libs.
Note some others have reported the same error. I wonder if it could be a bug?
If you have this problem on your local machine..
If you have just upgraded from rails 6 to 7, and have config.load_defaults 7.0 set in config/application.rb, then your app will use vips by default.
If that's what you want, just make sure vips is installed locally. You can install it with homebrew (thanks to #timroman for this info):
brew install vips
However, if you don't want to use vips, and prefer to use mini_magick as in rails 6, just include this line in config/application.rb
config.active_storage.variant_processor = :mini_magick
Notes
Moving from using :mini_magick to :vips will probably require code changes to make your application work as expected. See here for info on that.
Further reading:
Rails guides here and here
This PR
Installation instructions for macOS and Ubuntu
If you're having problems with vips on heroku..
If you get a similar issue on heroku, make sure everything works fine locally first (if it doesn't, see above), then to solve the issues on heroku, try the following 3 steps:
Add gem "ruby-vips" to your gemfile if it isn't already there
Set these two buildpacks (in addition to any you already have, in this example I was also using the heroku/ruby buildpack, hence why it's included as the last buildpack):
heroku-community/apt
https://github.com/brandoncc/heroku-buildpack-vips
heroku/ruby
I think the order here matters (if you have other buildpacks, best to add them after the first two). You can set buildpacks like this
heroku buildpacks:set --index=1 heroku-community/apt
heroku buildpacks:set --index=2 https://github.com/brandoncc/heroku-buildpack-vips
Create a file in the root directory of your app called Aptfile with this as the contents:
libglib2.0-0
libglib2.0-dev
libpoppler-glib8
Notes:
You may wish to add more libraries to the Aptfile depending on what processing needed exactly (for example, pdf processing). Here's an example of an Aptfile with more libraries included. And here is the rails guide showing which other things you may need.
Further reading:
Info on vips buildpack in this thread.
See here for vips buildpack
See here for information about the apt buildpack and Aptfile
If you're having problems on GitHub Actions
Just like other environments (see above) you have to install libvips. Do so on ubuntu using apt-get, by adding this under 'steps' in your workflow file:
- name: Install libvips
run: sudo apt-get install -y libvips
For Linux users just install using apt install libvips, if want to keep using the default load of Rails 7.
I used this Aptfile:
fonts-liberation
libreoffice-base-core
libreoffice-calc
libreoffice-writer
libreoffice
libpython2.7
pdf2htmlex
poppler-utils
And installation completed successfully. I even checked version of pdf2htmlEX in heroku bash.
pdf2htmlEX --version
pdf2htmlEX version 0.14.6
Copyright 2012-2015 Lu Wang <coolwanglu#gmail.com> and other contributors
Libraries:
poppler 0.41.0
libfontforge 20120731
Default data-dir: /usr/share/pdf2htmlEX
Supported image format: png jpg
But when I try to convert real PDF documents I'm getting this error:
Error: Cannot open the manifest file
I found on other sites that I need to run "make install" to fix this issue but not sure if it's possible with heroku.
Any help will be appreciated. Thanks
Similar answer on pdf2htmlEX
On heroki-18 I faced similar issue and resolved it by passing data-dir while converting.
If you are ruby you can use Kristin gem with master branch
look at this:
https://github.com/coolwanglu/pdf2htmlEX/issues/749
you just need to add the optional parameter --data-dir C:\<pdf2htmlex-folder>\data
to the command
I just completed Chapter One of the Ruby on Rails Tutorial by Hartl. Posted about one minor hitch previously. Now I started Chapter Two. I swear I did everything by the book, but now when I try:
git push -u origin master
I get the following messages after entering my passphrase:
ERROR: repository not found
fatal: could not read from remote repository
Please make sure you have the correct access rights and that the repository exists.
When I down loaded heroku tools I think it installed a second version of Ruby on my machine. In any case I now have two version listed under All Programs. Could this have screwed thing up? The two versions are Ruby 1.9.2-p290 and 1.9.3-p327. Also when I open the command prompt using 1.9.2 there is a weird thing at the top before I do anything:
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
This is then followed by the normal prompt on the next line. I'm wondering if the use of my public keys have some how gotten screwed up.
Any help would be appreciated.
You should add a new git remote.
check https://help.github.com/articles/adding-a-remote
So i had problems with windows and multiple versions of ruby too. I would recommend deinstalling all versions and only installing one ruby version. But thats not related to your Github problem i guess.
Switch via the commandline to your app folder and checkout:
git remote -v
it shows you what is the remote location for you app. And 5 bucks that its screwd up. You can remove the path by:
git remote rm origin
or if its only on heroku:
git remote rm heroku
and after that add the correct remote path again. Example:
git remote add origin git#github.com:foo/bar.git
That hopefuly fix it.
And keep in mind if you want to push to heroku use:
git push heroku master
I need to convert PDF to PNG on heroku, i'm using RMagick and for some PDF i run into this error :
Ghostscript 8.628.62: : Unrecoverable error, exit code 1 Unrecoverable
The same code runs fine on my local machine using Ghostscript 9.05
I would like to update the version of Ghostscript being used on Heroku and see if that solves the problem.
I followed these instruction to build ghostscript 9.05 on heroku :
http://theprogrammingbutler.com/blog/archives/2011/07/28/running-pdftotext-on-heroku/
My problem is vendoring the resulting package, how can i tell heroku to use my custom version of ghostscript instead of the system one ?
Here is what i tried :
Add the gs package under vendor/ghostscript/bin
Add it to the heroku path : heroku config:add PATH=vendor/ghostscript/bin:/usr/bin:/bin
My app still run on GS 8.62
Any help would be greatly appreciated !
Here are some ressources i tried to follow without success ...
https://devcenter.heroku.com/articles/buildpack-binaries
http://www.ryandaigle.com/a/using-vulcan-to-build-binary-dependencies-on-heroku
I'm trying to deploy an app that has a dependency on uuid.h. During the bundle install portion of the git push heroku master I get (what seems to be the key part of the backtrace):
checking for uuid/uuid.h... no
checking for uuid.h... no
configure: error: Neither uuid/uuid.h nor uuid.h found - required for brass, chert and flint (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)
Is there any way to get any of those libraries installed on the server? I'm guessing not by my own power, but just thought I'd ask.
If you're on the cedar stack, you can vendor in anything you want. It may not always be easy, but you'll be able to do it. Check out https://github.com/heroku/vulcan and projects on the heroku github account that have the word buildpack for inspiration.