Search code examples
ruby-on-railsubuntuenvironment-variablescapistranorjb

Deploying with Capistrano, JAVA_HOME is not being read


I am deploying with Capistrano and everything looked good until I got to Rjb part..

I can do

$ echo $JAVA_HOME
 /usr/lib/jvm/java-1.6.0-openjdk-amd64

More than that, I can do gem install rjb on server and it is getting installed...

However when I try:

$ cap bundle:install 

I get

** [out :: ec-...compute-1.amazonaws.com] extconf.rb:53:in `<main>': JAVA_HOME is not set. (RuntimeError)

Solution

  • Capistrano doesn't load the environment variables from the deployer machine or the deploy target; you'll have to specify them in your deploy.rb:

    set :default_environment, 'JAVA_HOME' => "/usr/lib/jvm/java-6-openjdk-amd64"