Can't deploy to Heroku the app with RJB gem
Asked Answered
I

6

5

I've set the JAVA_HOME variable

heroku config:add JAVA_HOME=/usr/lib/jvm/java-6-openjdk

checked that heroku config shows this variable with value, then pushed:

git push heroku master

and still get

JAVA_HOME is not set

error while bundler is installing RJB gem.

I can successfully deploy the same source to another Heroku application, and all environment variables are the same.

What is wrong?

Ito answered 22/3, 2012 at 13:42 Comment(1)
Just want to get the latest update from your end, because I'm trying to do the same thing. Did you manage to get it working on Heroku? Thanks.Arnulfo
A
8

I had the same question, and in case anyone else wants to know, this is what Heroku told me:

By default the config variables aren't made available when the application is compiled - only at runtime.

You can change this by making sure you have the latest heroku gem install, then enable the user_env_compile lab flag

$ heroku labs:enable user-env-compile

this will make JAVA_HOME available when the gem installs, hopefully getting you past this issue.

Aga answered 27/3, 2012 at 14:4 Comment(2)
The command changed, see here: devcenter.heroku.com/articles/labs-user-env-compileNester
this option is not available nowScuttlebutt
S
5

First find JAVA_HOME PATH by using,

heroku run 'which java |xargs  readlink -f  | sed "s:bin/java::"'

It will return you,

usr/lib/jvm/java-6-openjdk/jre

Using this now you came know about JAVA_HOME path on heroku. Now set JAVA_HOME path in heroku and in Gemfile

on heroku cli :

heroku config:add JAVA_HOME=/usr/lib/jvm/java-6-openjdk

In Gemfile on top :

java_home = '/usr/lib/jvm/java-6-openjdk'
ENV['JAVA_HOME'] = java_home if Dir.exist?(java_home)
Scuttlebutt answered 30/6, 2014 at 9:47 Comment(0)
V
2

Got Heroku to install gems that depend on $JAVA_HOME by adding the following to my Gemfile:

# set JAVA_HOME so Heroku will install gems that need it
heroku_java_home = '/usr/lib/jvm/java-6-openjdk'
ENV['JAVA_HOME'] = heroku_java_home if Dir.exist?(heroku_java_home)
Veld answered 18/2, 2013 at 23:52 Comment(0)
B
1

Have you tried deploying your app to a different stack?

I did a little searching and this seems to fit your explanation. https://github.com/carlhuda/bundler/issues/1742

probably yours report, isn't it?

I would advice you to contact Heroku and ask them to look into it.

It seems like it's missing dependencies which may, not be available on your current stack.

Brost answered 22/3, 2012 at 14:0 Comment(3)
Yes, it is my question on Github, and there is no solution. I can successfully deploy the same source to another Heroku application, and all environment variables are the same. I already have put request on Heroku, but they reply once a day and we are as always in a hurry :).Ito
But do the other application run on the same stack? (Cedar for instance) I doubt JAVA_HOME is the issue here, since it's failing during the making of rjb.Brost
Well then, I guess your only option is to get hold of Heroku. It has to be an issue on their end then.Brost
G
0

for migration from heroku cedar-14 to heroku-16 or heroku-18

$ heroku config:unset JAVA_HOME #remove JAVA_HOME env if exists
$ heroku stack:set heroku-18
$ heroku buildpacks:add --index 1 heroku/jvm
$ git push heroku master
Guidry answered 3/7, 2019 at 14:45 Comment(0)
F
0

To deploy to the heroku-20 stack, make sure you add the following build packs in this order:

heroku buildpacks:add heroku/jvm
heroku buildpacks:add heroku/ruby

You do NOT need to set JAVA_HOME manually with heroku-20. Nor will Heroku set it for you. The variable is already internally available to rjb when it is being installed.

Your final result should look like this:

enter image description here

Fermanagh answered 16/11, 2021 at 21:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.