Can't make erlport for ruby work in umbrella app on Heroku

Hi all!

I am running an Elixir umbrella app on Heroku. All is fine but one thing. I am using :erlport, github: "hdima/erlport" to run some Ruby code (asciidoctor-latex). This works locally but not on Heroku. (Heroku cannot help me as they do not support Elixir.)

I have narrowed the problem down to a single line. The app in question is http://notefile.herokuapp.com (https://github.com/jxxcarlson/ns_umbrella) and the line of code is in app/apps/ruby_bridge/priv/ruby/asciidoc.rb:

# require 'asciidoctor-latex'
require "/app/vendor/bundle/ruby/2.3.0/bundler/gems/asciidoctor-latex-
b5c9de1363de/bin/asciidoctor-latex"

With the commented-out line active, the apps works locally but not on Heroku. The other line is one of my (failed) experiments to supply require with a absolute pathto asciidoctor-latex.

I know that this line is the guilty party for the following reason. First, comment out all require lines; then,in asciidoc.rb, use result = "Text length = #{text.length}" instead of result = Asciidoctor.convert text, { 'dialect' => 'latex' }

Here I have replaced the call to a method in asciidoctor-latex by generic Ruby code. With these changes in place, the app does not crash and gives the expected output.

CONCLUSION: require cannot find its target. Below I’ve listed the buildpacks used (in order):

QUESTION: What is the correct require line. (I’ve tried various things based on the output of ruby -r rubygems -e "p Gem.path" and find . -name asciidoctor-latex, but have not succeeded).

heroku/ruby


Having near no knowledge of ruby, that looks to me like your asciidoctor-latex dependency is not installed on the ruby side? :slight_smile:

It is in

# Gemfile (at root of unbrella app)
gem 'asciidoctor-latex', :git => 'https://github.com/asciidoctor/asciidoctor-latex'

This works on my local machine and the ruby buildpack is supposed to run bundle in order to install it. I did do the following while logged into herroku to see is it was installed:

$ ruby -r rubygems -e "p Gem.path"
["/app/vendor/bundle/ruby/2.3.0", "/app/.gem/ruby/2.3.0", "/app/vendor/ruby-2.3.4/lib/ruby/gems/2.3.0"]

and also

$ find . -name asciidoctor-latex
./vendor/bundle/ruby/2.3.0/bin/asciidoctor-latex
./vendor/bundle/ruby/2.3.0/bundler/gems/asciidoctor-latex-b5c9de1363de/lib/asciidoctor-latex
./vendor/bundle/ruby/2.3.0/bundler/gems/asciidoctor-latex-b5c9de1363de/bin/asciidoctor-latex
./vendor/bundle/bin/asciidoctor-latex

You assume that the Ruby side is not able to find asciidoctor-latex, but could it also be the case that it CAN find that file but that the file is bad?

require returns a true or false value indicating whether or not it was successful. Do you know what value your require statement is returning?

Is there some way you can get at irb on the box and try using the gem manually to make sure that, for example, the gem is not crashing?

(did you require ‘rubygems’ before trying to require asciidoctor-latext)

2 Likes

One thung that has bitten me before, is that the ruby version that I ran manually on the box and the ruby version that is used by the daemon differ, resulting in the gem being installed at the wrong location, and thus not found.
What version manager do you use to manage the ruby version on your box?

Great suggestion. I tried this:

asciidoctor-latex --version
asciidoctor: WARNING: gem 'thread_safe' is not installed. This gem is recommended when registering custom converters.
Asciidoctor 1.5.5 [http://asciidoctor.org]
Runtime Environment (ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)

Thus I do know that the gem is installed (but I should also install thread-safe – its lack is not fatal, but it should be there)

Is there a way to find the path to asciidoctor-latex

Asciidoctor-latex is loaded from one of my repos at Github – should I also require it?

Is there a way to find the path to asciidoctor-latex

$ gem list --local -d

Good point!

On Heroku the ruby version is ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]. On my laptop it is 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]. I did run this:

asciidoctor-latex --version
asciidoctor: WARNING: gem 'thread_safe' is not installed. This gem is recommended when registering custom converters.
Asciidoctor 1.5.5 [http://asciidoctor.org]

so think that asciidoctor-latex does exist in the Heroko instance of the app. The output of the command on my laptop is the same as on Heroku, except for the Ruby version.