Not Able To Install Stanford-Core-NLP Gem - ruby

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.

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.

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.

Related

SQLite3 with JRuby and Sequel

I need to use SQLite3 with Jruby and Sequel gem on Windows.
require 'sequel'
DB = Sequel.sqlite
I got this error:
Sequel::AdapterNotFound: LoadError: no such file to load -- sqlite3
load_adapter at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:93
adapter_class at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:17
connect at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/database/connecting.rb:45
connect at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:116
adapter_method at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:394
block in sqlite at C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sequel-5.9.0/lib/sequel/core.rb:401
<main> at test.rb:53
When i try to install sqlite3 gem it fails when building native extensions:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/sqlite3-1.3.1
3/ext/sqlite3
C:/jruby-9.1.13.0/bin/jruby.exe -r ./siteconf20181005-6576-1e4h1cf.rb extconf.rb
checking for sqlite3.h... RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.
try_do at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:456
try_cpp at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:587
block in find_header at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:1144
block in checking_for at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:942
block in postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:320
block in postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:320
postpone at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:346
checking_for at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:941
find_header at C:/jruby-9.1.13.0/lib/ruby/stdlib/mkmf.rb:1143
<main> at extconf.rb:50
*** 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=C:/jruby-9.1.13.0/bin/jruby
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/jruby-9.1.13.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sql
ite3-1.3.13/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/jruby-9.1.13.0/lib/ruby/gems/shared/gems/s
qlite3-1.3.13 for inspection.
Results logged to C:/jruby-9.1.13.0/lib/ruby/gems/shared/extensions/universal-ja
va-1.8/2.3.0/sqlite3-1.3.13/gem_make.out
I've copied SQLite lib (sqlite3.dll, sqlite3.def) in jruby/bin folder.
JRuby official page sugget use activerecord-jdbc-adapter, but I need to create in memory db, not connecting to existing one.
How can I do?
My environment:
Jruby v. 9.1.13
Sequel v. 5.9.0
Windows Server 2012 R2
You want to use the Sequel jdbc adapter and the jdbc-sqlite3 gem:
require 'sequel'
DB = Sequel.connect("jdbc:sqlite::memory:")
FWIW, if you want an in-memory database with JRuby, h2, hsqldb, and derby may be better choices (and Sequel supports all of them).

rbczmq error when installing iruby

Am trying to install iruby on a windows machine and this error keeps appearing. Am currently doing some deep learning and I need to use sciruby and iruby to perform the actions required
PS C:\> gem install iruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing iruby:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe -r ./siteconf20150710-76680-1u0zekx.rb extconf.rb
checking for windows.h... yes
checking for winsock.h... yes
checking for main() in -lkernel32... yes
checking for main() in -lrpcrt4... yes
checking for main() in -lgdi32... yes
*** 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=C:/RailsInstaller/Ruby2.1.0/bin/ruby
--with-kernel32lib
--without-kernel32lib
--with-rpcrt4lib
--without-rpcrt4lib
--with-gdi32lib
--without-gdi32lib
extconf.rb:49:in `<main>': uninitialized constant GNU_CHAIN (NameError)
extconf failed, exit code 1
Gem files will remain installed in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rbczmq-1.7.9 for inspection.
Results logged to C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/rbczmq-1.7.9/gem_make.out
Please assist solving this problem
I am new to python and know nothing about ruby, but I find ipython notebook so amazing that I want give it a try for another kernel,
so I just installed ruby and end up with the same problem, and google failed to help me,,,
but I am really good at patching things, after one hour of ##$#%&%#%!(#!, I found a way:
edit C:\Ruby22-x64\lib\ruby\gems\2.2.0\gems\rbczmq-1.7.9\ext\rbczmq\extconf.rb
add statement GNU_CHAIN = 1 on the top
cd C:\Ruby22-x64\lib\ruby\gems\2.2.0\gems\rbczmq-1.7.9
gem spec ....\cache\rbczmq-1.7.9.gem --ruby > ....\specifications\rbczmq-1.7.9.gem.gemspec
gem build ....\specifications\rbczmq-1.7.9.gem.gemspec
now, gem list shows "rbczmq (1.7.9)"
I knew nothing about ruby, so I dont know whether rbczmq really works or not
"iruby notebook" starts succ and new kernel "ruby 2.2.2" added, but it also says "kernel error" when I choose it
the Track back says: "OSError: [WinError 193]"
That's all I can help for now, so maybe you can figure it out now and tell me how to make the new kernel do its trick

Debugger cannot compile on Ruby 2.0

Originally posted here: "How to use the debugger with Ruby 2.0?"
I keep ending up back here, but I have a different problem. I don't have the option to change to Byebug right now. We are currently stuck on "debugger" for now, and I cannot install it.
Building native extensions. This could take a while...
ERROR: Error installing debugger:
ERROR: Failed to build gem native extension.
/Users/mbridges/.rbenv/versions/2.0.0-p247/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=/Users/mbridges/.rbenv/versions/2.0.0-p247/bin/ruby
/Users/mbridges/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require': cannot load such file -- debugger/ruby_core_source (LoadError)
from /Users/mbridges/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
from extconf.rb:16:in `<main>'
Anyone have any ideas?
Update: Now Ruby 2.1+ should using byebug instead of debugger.
clone the debugger-ruby_core_source to local folder, e.g. C:\git\debugger-ruby_core_source
copy C:\git\debugger-ruby_core_source\lib to C:\Ruby200\lib\ruby\gems\2.0.0\gems\debugger-ruby_core_source-1.3.2
run the gem install debugger again.
I'm now sure why the gems debugger-ruby_core_source didn't copy the lib to that folder, but certainly the debugger need it.

Installing opencv GEM - extconf.rb error

I have been stuck on this for a couple of days now, so PLEASE help!
I run MAC OS X(10.7.5), with Xcode(4.5.2) and Command Line Tools installed. Ruby 1.9.3-p362, RVM 1.17.8. apple-gcc42 has also been installed. I use Homebrew for installations.
When I try to install the Opencv gem, I get the following error:
*** 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
--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=/Users/samanthacabral/.rvm/rubies/ruby-1.9.3-p362/bin/ruby
--with-opencv-dir
--without-opencv-dir
--with-opencv-include
--without-opencv-include=${opencv-dir}/include
--with-opencv-lib
--without-opencv-lib=${opencv-dir}/lib
--with-ffcall-dir
--without-ffcall-dir
--with-ffcall-include
--without-ffcall-include=${ffcall-dir}/include
--with-ffcall-lib
--without-ffcall-lib=${ffcall-dir}/lib
--with-cxcorelib
--without-cxcorelib
extconf.rb:32:in `block in <main>': libcxcore not found. (RuntimeError)
from extconf.rb:31:in `each'
from extconf.rb:31:in `<main>'
I have tried reinstalling RVM a couple of times and making some of the other changes recommended in similar questions.
My gem file compiles just fine without the opencv gem, but I am having similar issues with RMagick (showing an extconf.rb error).
What should I do?
Thanks!!!
In case anyone else experiences this, I had better similar problems on OS X and had better luck with the ruby-opencv gem.

Error installing rmagick: ERROR: Failed to build gem native extension

I am trying to install RmMagic using the below command:
gem install rmagick -v=2.12.2
After running this command i get some error :
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
D:/ruby/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
Invalid drive specification.
Unable to get ImageMagick version
*** 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=D:/ruby/bin/ruby
Gem files will remain installed in D:/ruby/lib/ruby/gems/1.8/gems/rmagick-2
.12.2 for inspection.
Results logged to D:/ruby/lib/ruby/gems/1.8/gems/rmagick-2.12.2/ext/RMagick
/gem_make.out
Please help me in this regard. Thanks in advance.
I had same problem with rmagick to solve this add System Environment Variable
CLASSPATH .;C:\ImageMagick-6.5.6-Q8\include
lib C:\ImageMagick-6.5.6-Q8\lib
Then do
gem install rmagick --platform=ruby -- --with-opt-lib=C:\ImageMagick-6.5.6-Q8\lib --with-opt-include=C:\ImageMagick-6.5.6-Q8\include
What a pain this was... I definitely needed to do both the System Environment Variables AND the specific syntax of the command as suggested by Mukesh
To clarify the two steps:(for other novices like me)
Click properties from context menu of "Computer, click "Advanced System Settings",
click "Environment Variables", click "New" under System Variables,
use CLASSPATH for the variable name and for the value use:
.;C:\ImageMagick-6.9.0-Q16\include;lib C:\ImageMagick-6.9.0-Q16\lib
Then Run As Administrator the Command Prompt with Ruby terminal and execute:
gem install rmagick -v '2.13.4' -- --with-opt-lib=C:\ImageMagick-6.9.0-Q16\lib --with-opt-include=C:\ImageMagick-6.9.0-Q16\include
(***Make sure to update the versions number in both the Variable and gem command if necessary)

Resources