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?

Paul
  • 25,812
  • 38
  • 124
  • 247
  • 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. – toy May 08 '12 at 14:48

6 Answers6

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.

Gabe Kopley
  • 16,281
  • 5
  • 47
  • 60
James W
  • 96
  • 1
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)
Rahul Chaudhari
  • 2,230
  • 21
  • 29
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)
Josh
  • 21
  • 1
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.

martinjlowm
  • 871
  • 5
  • 8
  • 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 :). – Paul Mar 22 '12 at 14:11
  • 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. – martinjlowm Mar 22 '12 at 14:21
  • Well then, I guess your only option is to get hold of Heroku. It has to be an issue on their end then. – martinjlowm Mar 22 '12 at 14:31
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
Sergey
  • 345
  • 3
  • 12
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

Vadim
  • 1,916
  • 2
  • 19
  • 39