Closed edborden closed 9 years ago
Hey @edborden, check out https://github.com/gjtorikian/math-web. It's a bit out-of-date, but it's a server that uses mathematical to output SVG (or PNG), given an equation. Let me know if that works for you.
I pulled that repository into Heroku and deployed and got:
-----> Ruby app detected
-----> Compiling Ruby/Rack
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using bundler 1.9.7
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Rubygems 2.0.14 is not threadsafe, so your gems must be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Installing rake 10.4.2
Installing kgio 2.9.2
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/tmp/build_0c4c49cd11a6459a45a8bd1bbef26307/edborden-math-web-f6da723/vendor/ruby-2.0.0/bin/ruby extconf.rb
checking for main() in -lxml2... yes
checking for libxml/tree.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/parser.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/xpath.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/xpathInternals.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
make: *** No targets specified and no makefile found. Stop.
checking for main() in -lpangocairo-1.0... no
Package pango was not found in the pkg-config search path.
Perhaps you should add the directory containing `pango.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pango' found
Package pango was not found in the pkg-config search path.
Perhaps you should add the directory containing `pango.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pango' found
creating Makefile
make "DESTDIR="
compiling lsmsvgclippathelement.c
In file included from ./lsmsvgtypes.h:27:0,
from ./lsmsvgclippathelement.h:27,
from lsmsvgclippathelement.c:24:
./lsmsvgenums.h:27:25: fatal error: glib-object.h: No such file or directory
#include <glib-object.h>
^
compilation terminated.
make: *** [lsmsvgclippathelement.o] Error 1
Gem files will remain installed in /tmp/build_0c4c49cd11a6459a45a8bd1bbef26307/edborden-math-web-f6da723/vendor/bundle/ruby/2.0.0/gems/mathematical-1.2.0 for inspection.
Results logged to /tmp/build_0c4c49cd11a6459a45a8bd1bbef26307/edborden-math-web-f6da723/vendor/bundle/ruby/2.0.0/gems/mathematical-1.2.0/ext/mathematical/gem_make.out
An error occurred while installing mathematical (1.2.0), and Bundler cannot
continue.
Make sure that `gem install mathematical -v '1.2.0'` succeeds before bundling.
Bundler Output: Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Rubygems 2.0.14 is not threadsafe, so your gems must be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Installing rake 10.4.2
Installing kgio 2.9.2
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/tmp/build_0c4c49cd11a6459a45a8bd1bbef26307/edborden-math-web-f6da723/vendor/ruby-2.0.0/bin/ruby extconf.rb
checking for main() in -lxml2... yes
checking for libxml/tree.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/parser.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/xpath.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
checking for libxml/xpathInternals.h in /include/libxml2,/usr/include/libxml2,/usr/local/include/libxml2... yes
make: *** No targets specified and no makefile found. Stop.
checking for main() in -lpangocairo-1.0... no
Package pango was not found in the pkg-config search path.
Perhaps you should add the directory containing `pango.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pango' found
Package pango was not found in the pkg-config search path.
Perhaps you should add the directory containing `pango.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pango' found
creating Makefile
make "DESTDIR="
compiling lsmsvgclippathelement.c
In file included from ./lsmsvgtypes.h:27:0,
from ./lsmsvgclippathelement.h:27,
from lsmsvgclippathelement.c:24:
./lsmsvgenums.h:27:25: fatal error: glib-object.h: No such file or directory
#include <glib-object.h>
^
compilation terminated.
make: *** [lsmsvgclippathelement.o] Error 1
Gem files will remain installed in /tmp/build_0c4c49cd11a6459a45a8bd1bbef26307/edborden-math-web-f6da723/vendor/bundle/ruby/2.0.0/gems/mathematical-1.2.0 for inspection.
Results logged to /tmp/build_0c4c49cd11a6459a45a8bd1bbef26307/edborden-math-web-f6da723/vendor/bundle/ruby/2.0.0/gems/mathematical-1.2.0/ext/mathematical/gem_make.out
An error occurred while installing mathematical (1.2.0), and Bundler cannot
continue.
Make sure that `gem install mathematical -v '1.2.0'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app
Ah, yeah, I had to spin up a DigitalOcean server to support this, because Heroku didn't have the appropriate C libraries to pull it off. At least, at the time (~a year ago), I couldn't figure it out. Maybe things have changes?
I saw you have a repository for a pango buildpack, did that not work?
No. :cry: Again, this was all about a year ago, so maybe the circumstances have changed.
Heroku has libpango
but not the dev files on it. You can install them using the apt buildpack (https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-apt) and this package libpango1.0-dev
found from https://packages.ubuntu.com/search?keywords=pango&searchon=names&suite=bionic§ion=all.
You can see it work on a docker image:
docker run -it --rm heroku/heroku:18-build bash
Then
apt-get update
apt-get install libpango1.0-dev
After that, then i'm able to get a result from pkg-config
:
root@0ab4575f64e7:/# pkg-config --static --libs glib-2.0 gdk-pixbuf-2.0 cairo pango
-lgdk_pixbuf-2.0 -lm -lgmodule-2.0 -pthread -ldl -lpng16 -lm -lz -lm -lcairo -lz -lpixman-1 -lfontconfig -lexpat -lfreetype -lexpat -lfreetype -lpng16 -lm -lz -lm -lz -lxcb-shm -lxcb-render -lXrender -lXext -lX11 -lpthread -lxcb -lXau -lXdmcp -lpango-1.0 -lm -lgobject-2.0 -lffi -lglib-2.0 -pthread -lpcre -pthread
So that might be enough to get you going.
Also to note, we recommend against statically linking against system binaries. If there were a security update and the gem you're using is statically compiled then it won't receive the security updates after we've updated our packages on the stack image.
Any guidance on getting this running on Heroku on Rails? I need a service that can convert latex to png via an API, would this be a good engine for that? I'm not really sure how to get it running with all of the external dependencies, how would Heroku pick them up?