HMLDude
HMLDude

Reputation: 1637

Not Able To Install Stanford-Core-NLP Gem

I am trying to install the Stanford-Core-NLP gem, which is one of the major projects on github for natural language processing using Ruby. It provides Ruby bindings for the Stanford-Core-NLP pakage, which where written in Java. When I try following the first step of the the installation instructions, which is:

gem install stanford-core-nlp

I get the following error:

ERROR:  Error installing stanford-core-nlp:
ERROR: Failed to build gem native extension.

/home/user/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/user/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
extconf.rb:53:in `<main>': JAVA_HOME is not set. (RuntimeError)

I am running Ruby 1.9.2, which according to the repo, is the latest version the gem has been tested on and Java 1.7.0_40. I also tried looking for the mkmf.log file, but was unable to locate it.

Upvotes: 2

Views: 906

Answers (2)

Neville Kuyt
Neville Kuyt

Reputation: 29649

I've been wrestling with this on Ubuntu. The thing that works reliably (though it is a sledgehammer) is:

JAVA_HOME=/usr/lib/whatever gem install stanford-core-nlp

The installation script is sensitive to the format of JAVA_HOME - it shouldn't end in a slash character.

Upvotes: 0

Asheesh
Asheesh

Reputation: 463

This is because JAVA_HOME is getting reset in the sudo mode. To fix it, open your /etc/sudoers file add the following line and save it.

Defaults   env_keep += "JAVA_HOME"

now reopen the terminal and install the gem.

Upvotes: 4

Related Questions