RJB works fine on Heroku Cedar, inexplicably broken on Cedar 14?

698 Views Asked by At

So like a good programmer should, I'm preparing an application for the upcoming transition to Cedar-14.

Program works fine on Cedar 10. Doesn't work on Cedar 14, some kind of problem with RJB. When I try to push the app here's the error I get:

Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 635 bytes | 0 bytes/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.1.5
remote: -----> Installing dependencies using 1.9.7
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Fetching gem metadata from https://rubygems.org/...........
remote:        Fetching version metadata from https://rubygems.org/...
remote:        Fetching dependency metadata from https://rubygems.org/..
remote:        Using rake 10.4.2
remote:        Using i18n 0.7.0
remote:        Using json 1.8.3
remote:        Using minitest 5.8.0
remote:        Using thread_safe 0.3.5
remote:        Using builder 3.2.2
remote:        Using erubis 2.7.0
remote:        Using rack 1.5.5
remote:        Using mime-types 1.25.1
remote:        Using polyglot 0.3.5
remote:        Using arel 5.0.1.20140414130214
remote:        Using bcrypt 3.1.10
remote:        Using sass 3.2.19
remote:        Using cancancan 1.12.0
remote:        Using cocoon 1.2.6
remote:        Using coffee-script-source 1.9.1.1
remote:        Using CFPropertyList 2.3.1
remote:        Using execjs 2.5.2
remote:        Using thor 0.19.1
remote:        Using commonjs 0.2.7
remote:        Using currencies 0.4.2
remote:        Using i18n_data 0.7.0
remote:        Using orm_adapter 0.5.0
remote:        Using excon 0.45.4
remote:        Using formatador 0.2.5
remote:        Using net-ssh 2.9.2
remote:        Using mini_portile 0.6.2
remote:        Using multi_json 1.11.2
remote:        Using ipaddress 0.8.0
remote:        Using inflecto 0.0.2
remote:        Using tilt 1.4.1
remote:        Using sexp_processor 4.6.0
remote:        Using hike 1.2.3
remote:        Using libv8 3.16.14.11
remote:        Using nested_form 0.3.2
remote:        Using pdf-core 0.2.5
remote:        Using pdf-merger 0.3.2
remote:        Using pg 0.18.2
remote:        Using phony 2.14.13
remote:        Using ttfunk 1.2.2
remote:        Using bundler 1.9.7
remote:        Using rails_serve_static_assets 0.0.4
remote:        Using rails_stdout_logging 0.0.3
remote:        Using ref 2.0.0
remote:        Using tlsmail 0.0.1
remote:        Using rdoc 4.2.0
remote:        Using tzinfo 1.2.2
remote:        Using rack-test 0.6.3
remote:        Using warden 1.2.3
remote:        Using rack-cache 1.2
remote:        Using treetop 1.4.15
remote:        Using bootstrap-sass 3.1.1.1
remote:        Using validates_email_format_of 1.6.3
remote:        Using coffee-script 2.4.1
remote:        Using uglifier 2.7.1
remote:        Using figaro 1.1.1
remote:        Using less 2.6.0
remote:        Using net-scp 1.2.1
remote:        Using nokogiri 1.6.6.2
remote:        Using countries 0.11.5
remote:        Using haml 4.0.6
remote:        Using ruby_parser 3.7.1
remote:        Using prawn 1.1.0
remote:        Using rails_12factor 0.0.3
remote:        Using therubyracer 0.12.2
remote:        Using sprockets 2.12.4
remote:        Using sdoc 0.4.1
remote:        Using activesupport 4.1.0
remote:        Using fission 0.5.0
remote:        Using mail 2.5.4
remote:        Using fog-core 1.32.0
remote:        Using html2haml 2.0.0
remote:        Using actionview 4.1.0
remote:        Using activemodel 4.1.0
remote:        Using climate_control 0.0.3
remote:        Using jbuilder 1.5.3
remote:        Using phony_rails 0.12.9
remote:        Using fog-xml 0.1.2
remote:        Using fog-json 1.0.2
remote:        Using fog-local 0.2.1
remote:        Using actionpack 4.1.0
remote:        Using activerecord 4.1.0
remote:        Using carrierwave 0.10.0
remote:        Using cocaine 0.5.7
remote:        Using fog-vmfusion 0.1.0
remote:        Using fog-brightbox 0.8.0
remote:        Using fog-sakuracloud 1.0.1
remote:        Using fog-serverlove 0.1.2
remote:        Using fog-softlayer 0.4.7
remote:        Using fog-storm_on_demand 0.1.1
remote:        Using fog-atmos 0.1.0
remote:        Using fog-aws 0.7.4
remote:        Using fog-ecloud 0.1.1
remote:        Using fog-google 0.0.7
remote:        Using fog-powerdns 0.1.1
remote:        Using fog-profitbricks 0.0.5
remote:        Using fog-radosgw 0.0.4
remote:        Using fog-riakcs 0.1.0
remote:        Using fog-terremark 0.1.0
remote:        Using fog-voxel 0.1.0
remote:        Using actionmailer 4.1.0
remote:        Using railties 4.1.0
remote:        Using formtastic 2.2.1
remote:        Using less-rails 2.7.0
remote:        Using sprockets-rails 2.3.2
remote:        Using paperclip 4.2.4
remote:        Using fog 1.32.0
remote:        Using coffee-rails 4.0.1
remote:        Using responders 1.1.2
remote:        Using haml-rails 0.9.0
remote:        Using jquery-rails 3.1.3
remote:        Using formtastic-bootstrap 3.0.0
remote:        Using rails 4.1.0
remote:        Using mail_form 1.5.0 from git://github.com/plataformatec/mail_form (at master)
remote:        Using sass-rails 4.0.5
remote:        Using less-rails-bootstrap 3.3.5.0
remote:        Using turbolinks 2.5.3
remote:        Using devise 3.5.1
remote:        Using prawnto_2 0.2.6
remote:        Using rails_autolink 1.1.6
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        /tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/ruby-2.1.5/bin/ruby extconf.rb
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probably lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote:        need configuration options.
remote:        Provided configuration options:
remote:        --with-opt-dir
remote:        --without-opt-dir
remote:        --with-opt-include
remote:        --without-opt-include=${opt-dir}/include
remote:        --with-opt-lib
remote:        --without-opt-lib=${opt-dir}/lib
remote:        --with-make-prog
remote:        --without-make-prog
remote:        --srcdir=.
remote:        --curdir
remote:        --ruby=/tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/ruby-2.1.5/bin/ruby
remote:        extconf.rb:39:in `<main>': JAVA_HOME is not directory. (RuntimeError)
remote:        extconf failed, exit code 1
remote:        Gem files will remain installed in /tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/bundle/ruby/2.1.0/gems/rjb-1.5.3 for inspection.
remote:        Results logged to /tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0-static/rjb-1.5.3/gem_make.out
remote:        An error occurred while installing rjb (1.5.3), and Bundler cannot continue.
remote:        Make sure that `gem install rjb -v '1.5.3'` succeeds before bundling.
remote:        Bundler Output: Fetching gem metadata from https://rubygems.org/...........
remote:        Fetching version metadata from https://rubygems.org/...
remote:        Fetching dependency metadata from https://rubygems.org/..
remote:        Using rake 10.4.2
remote:        Using i18n 0.7.0
remote:        Using json 1.8.3
remote:        Using minitest 5.8.0
remote:        Using thread_safe 0.3.5
remote:        Using builder 3.2.2
remote:        Using erubis 2.7.0
remote:        Using rack 1.5.5
remote:        Using mime-types 1.25.1
remote:        Using polyglot 0.3.5
remote:        Using arel 5.0.1.20140414130214
remote:        Using bcrypt 3.1.10
remote:        Using sass 3.2.19
remote:        Using cancancan 1.12.0
remote:        Using cocoon 1.2.6
remote:        Using coffee-script-source 1.9.1.1
remote:        Using CFPropertyList 2.3.1
remote:        Using execjs 2.5.2
remote:        Using thor 0.19.1
remote:        Using commonjs 0.2.7
remote:        Using currencies 0.4.2
remote:        Using i18n_data 0.7.0
remote:        Using orm_adapter 0.5.0
remote:        Using excon 0.45.4
remote:        Using formatador 0.2.5
remote:        Using net-ssh 2.9.2
remote:        Using mini_portile 0.6.2
remote:        Using multi_json 1.11.2
remote:        Using ipaddress 0.8.0
remote:        Using inflecto 0.0.2
remote:        Using tilt 1.4.1
remote:        Using sexp_processor 4.6.0
remote:        Using hike 1.2.3
remote:        Using libv8 3.16.14.11
remote:        Using nested_form 0.3.2
remote:        Using pdf-core 0.2.5
remote:        Using pdf-merger 0.3.2
remote:        Using pg 0.18.2
remote:        Using phony 2.14.13
remote:        Using ttfunk 1.2.2
remote:        Using bundler 1.9.7
remote:        Using rails_serve_static_assets 0.0.4
remote:        Using rails_stdout_logging 0.0.3
remote:        Using ref 2.0.0
remote:        Using tlsmail 0.0.1
remote:        Using rdoc 4.2.0
remote:        Using tzinfo 1.2.2
remote:        Using rack-test 0.6.3
remote:        Using warden 1.2.3
remote:        Using rack-cache 1.2
remote:        Using treetop 1.4.15
remote:        Using bootstrap-sass 3.1.1.1
remote:        Using validates_email_format_of 1.6.3
remote:        Using coffee-script 2.4.1
remote:        Using uglifier 2.7.1
remote:        Using figaro 1.1.1
remote:        Using less 2.6.0
remote:        Using net-scp 1.2.1
remote:        Using nokogiri 1.6.6.2
remote:        Using countries 0.11.5
remote:        Using haml 4.0.6
remote:        Using ruby_parser 3.7.1
remote:        Using prawn 1.1.0
remote:        Using rails_12factor 0.0.3
remote:        Using therubyracer 0.12.2
remote:        Using sprockets 2.12.4
remote:        Using sdoc 0.4.1
remote:        Using activesupport 4.1.0
remote:        Using fission 0.5.0
remote:        Using mail 2.5.4
remote:        Using fog-core 1.32.0
remote:        Using html2haml 2.0.0
remote:        Using actionview 4.1.0
remote:        Using activemodel 4.1.0
remote:        Using climate_control 0.0.3
remote:        Using jbuilder 1.5.3
remote:        Using phony_rails 0.12.9
remote:        Using fog-xml 0.1.2
remote:        Using fog-json 1.0.2
remote:        Using fog-local 0.2.1
remote:        Using actionpack 4.1.0
remote:        Using activerecord 4.1.0
remote:        Using carrierwave 0.10.0
remote:        Using cocaine 0.5.7
remote:        Using fog-vmfusion 0.1.0
remote:        Using fog-brightbox 0.8.0
remote:        Using fog-sakuracloud 1.0.1
remote:        Using fog-serverlove 0.1.2
remote:        Using fog-softlayer 0.4.7
remote:        Using fog-storm_on_demand 0.1.1
remote:        Using fog-atmos 0.1.0
remote:        Using fog-aws 0.7.4
remote:        Using fog-ecloud 0.1.1
remote:        Using fog-google 0.0.7
remote:        Using fog-powerdns 0.1.1
remote:        Using fog-profitbricks 0.0.5
remote:        Using fog-radosgw 0.0.4
remote:        Using fog-riakcs 0.1.0
remote:        Using fog-terremark 0.1.0
remote:        Using fog-voxel 0.1.0
remote:        Using actionmailer 4.1.0
remote:        Using railties 4.1.0
remote:        Using formtastic 2.2.1
remote:        Using less-rails 2.7.0
remote:        Using sprockets-rails 2.3.2
remote:        Using paperclip 4.2.4
remote:        Using fog 1.32.0
remote:        Using coffee-rails 4.0.1
remote:        Using responders 1.1.2
remote:        Using haml-rails 0.9.0
remote:        Using jquery-rails 3.1.3
remote:        Using formtastic-bootstrap 3.0.0
remote:        Using rails 4.1.0
remote:        Using mail_form 1.5.0 from git://github.com/plataformatec/mail_form (at master)
remote:        Using sass-rails 4.0.5
remote:        Using less-rails-bootstrap 3.3.5.0
remote:        Using turbolinks 2.5.3
remote:        Using devise 3.5.1
remote:        Using prawnto_2 0.2.6
remote:        Using rails_autolink 1.1.6
remote:        
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        
remote:        /tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/ruby-2.1.5/bin/ruby extconf.rb
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probably lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote:        need configuration options.
remote:        
remote:        Provided configuration options:
remote:        --with-opt-dir
remote:        --without-opt-dir
remote:        --with-opt-include
remote:        --without-opt-include=${opt-dir}/include
remote:        --with-opt-lib
remote:        --without-opt-lib=${opt-dir}/lib
remote:        --with-make-prog
remote:        --without-make-prog
remote:        --srcdir=.
remote:        --curdir
remote:        --ruby=/tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/ruby-2.1.5/bin/ruby
remote:        extconf.rb:39:in `<main>': JAVA_HOME is not directory. (RuntimeError)
remote:        
remote:        extconf failed, exit code 1
remote:        
remote:        Gem files will remain installed in /tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/bundle/ruby/2.1.0/gems/rjb-1.5.3 for inspection.
remote:        Results logged to /tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0-static/rjb-1.5.3/gem_make.out
remote:        An error occurred while installing rjb (1.5.3), and Bundler cannot continue.
remote:        Make sure that `gem install rjb -v '1.5.3'` succeeds before bundling.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy...
remote: 

... and then the usual "push rejected".

Obviously the key part is

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        
remote:        /tmp/build_fefc826e1bdbba09c960a4c215f98122/vendor/ruby-2.1.5/bin/ruby extconf.rb
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probably lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote:        need configuration options.

which is related either to pg or 'rjb`.

On the cedar 10 version, I had locked rjb to v1.4.9. This nevertheless caused the same problem on cedar 14 and upgrading it to v1.5.3 hasn't helped.

The app works totally fine in development if I just remove the rjb gem entirely, but then breaks completely when uploaded to Heroku ("An error occurred with your application, please try again in a few minutes" screen of death).

I've had a look at this similar question but heroku appears to have removed the "labs" addition that was the suggested solution. I've also messed around with ENV['JAVA_HOME'] in my Gemfile to no results.

I'm out of ideas, and I can't even find any information on how to check the mkmf.log file on Heroku for any extra clues.

gem install rjb -v '1.5.3' works fine on its own, but doesn't change anything when I try to push the whole application.

How do I check the mkmf.log files on Heroku?

Is there an alternative to rjb that I can try (obviously Heroku feels it needs it for something, likely PDF generation with prawn)? I've read a little about Jruby but apparently a lot of other gems are not supported in that and so the rest of my application probably wouldn't work.

Is there some other obvious or existing solution that I'm missing?

Here's my Gemfile:

source 'https://rubygems.org'

ruby '2.1.5'

# Required to get rjb (and therefore PDF merger) working on Heroku
# https://stackoverflow.com/questions/9823487/cant-deploy-to-heroku-the-app-with-rjb-gem/9891161#9891161
# This directory changed from Heroku "cedar" stack to "cedar 14" stack
# It may need to be updated if Heroku updates their stack again, and rjb/pg will not install
# Will throw an error like this
# Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
# remote:        
# remote:        /tmp/build_943bcf5ec8b7d2ff7b74f56f3b28db62/vendor/ruby-2.1.5/bin/ruby extconf.rb
# remote:        *** extconf.rb failed ***
# remote:        Could not create Makefile due to some reason, probably lack of necessary
# remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
# remote:        need configuration options.
java_home = '/usr/lib/jvm/java-6-openjdk'
ENV['JAVA_HOME'] = java_home if Dir.exist?(java_home)
gem 'rjb'

gem 'rails', '4.1.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'pg' # Use postgresql as the database for Active Record
gem 'sass-rails', '~> 4.0.0' # Use SCSS for stylesheets
gem 'bootstrap-sass', '~> 3.1.1'
gem 'uglifier', '>= 1.3.0' # Use Uglifier as compressor for JavaScript assets
gem 'coffee-rails', '~> 4.0.0' # Use CoffeeScript for .js.coffee assets and views
gem 'jquery-rails' # Use jquery as the JavaScript library
gem 'turbolinks' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'jbuilder', '~> 1.2' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
gem 'less-rails-bootstrap'

gem 'devise'
gem 'cancancan', '~> 1.9'
gem 'formtastic', '2.2.1'
gem 'formtastic-bootstrap'
gem 'cocoon'
gem 'haml'
gem 'haml-rails'
gem 'rails_autolink'
gem 'validates_email_format_of'
gem 'figaro'

gem 'prawn', '1.1.0' # Updating this breaks the 'prawn/table functionality'
gem 'prawnto_2', '0.2.6', :require => "prawnto"
#gem 'prawn-templates'
gem 'paperclip', '~> 4.2.0'
gem 'tlsmail', require: false # See config/initializers/tlsmail.rb
gem 'carrierwave'
gem 'fog'
gem 'nested_form'
gem 'phony_rails'
gem 'pdf-merger'

gem 'mail_form', :git => 'git://github.com/plataformatec/mail_form'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

group :development, :test do
  gem 'rspec-rails'
  gem 'rspec-activemodel-mocks'
  gem 'factory_girl_rails'
  gem 'better_errors'
  gem 'binding_of_caller'
end

group :test do
  gem 'shoulda-matchers'
  gem 'database_cleaner'
  gem 'selenium-webdriver'
  gem 'faker'
  gem 'capybara'
  gem 'launchy'
  gem 'pdf-inspector', require: "pdf/inspector"
end

group :production do
  gem 'rails_12factor' # Enable Heroku production
  gem 'rack-cache' # Enable rack-caching for production environment and Prawn email attachment
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development
1

There are 1 best solutions below

2
On BEST ANSWER

On cedar-14 you must set JAVA_HOME to /usr/lib/jvm/java-1.7.0-openjdk-amd64/