Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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)

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)

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.

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top