SQLite3 with JRuby and Sequel - ruby

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).

Related

Unable to install cucumber gem

I'm trying to setup ruby/cucumber tool on my windows 7 PC, I've installed Ruby 2.1.5 and devkit and got installed all the gems except Cucumber.
I'm getting the following error while install cucumber gem.Please help me on this.
ERROR:
Following gems were not installed:
cucumber (2.0.0.rc.4): Error installing cucumber:
ERROR: Failed to build gem native extension. C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150308-6692-1kwvlbm.rb extconf.rb checking for main() in -lc... * 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. Temporarily enhancing PATH to include DevKit... Provided configuration options: Building native extensions. This could take a while... --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:/Ruby22-x64/bin/$(RUBY_BASE_NAME) --with-gherkin_lexer_ar-dir --without-gherkin_lexer_ar-dir --with-gherkin_lexer_ar-include --without-gherkin_lexer_ar-include=${gherkin_lexer_ar-dir}/include --with-gherkin_lexer_ar-lib --without-gherkin_lexer_ar-lib=${gherkin_lexer_ar-dir}/lib --with-clib --without-clib C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:541:intry_link0' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:556:in try_link' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:735:intry_func' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:966:in block in have_library' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:911:inblock in checking_for' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:351:in block (2 levels) in postpone' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:321:inopen' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:351:in block in postpone' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:321:inopen' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:347:in postpone' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:910:inchecking_for' from C:/Ruby22-x64/lib/ruby/2.2.0/mkmf.rb:961:in have_library' from extconf.rb:5:in' extconf failed, exit code 1 Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/gherkin-2.12.2 for inspection. Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/gherkin-2.12.2/gem_make.out
Are you able to try using the current HEAD?
You can specify gem 'cucumber', github: 'cucumber/cucumber' in a Gemfile and try bundle installl

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.

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.
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.

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