Cannot install SQLITE3 with JRuby

2019-04-26 16:03发布

问题:

I am brand new to Ruby and using Windows 7. It is a different environment to what I am normally used to so I am having problems getting a simple project going.

After reading several tutorials, it appears that JRuby is the simplest way to go on windows which I have done. I am now trying to create a web application from scratch but I am confused about this shell style method of working.

I have downloaded sqliste3.def, sqlite3.dll and sqlite3 which I have put in the: C:jruby-1.6.4>bin directory. However, I am now trying to install sqlite but with no avail. Firstly what I would like to know is which console environment does one use to do this. Is this cmd or the IRB console?

Whenever I use cmd the default line is c:\users\me> and I don't know if this is affecting how things should work.

Whenever I try to install SQLITE3 I am assuming that i need to go :

c:\users\me>gem install sqlite3-ruby

However I am not getting anywhere and receiving the following error:

WARNING:JRuby does not support native extensions or the 'mkmf' library very well

I have heard a lot of good things about Ruby and I am simply trying to build a basic webpage with a contact form but I seem to be running into all sorts of issues with the project installation and simply getting ruby up and running. Are there any tutorials that explain how to start a web project with JRuby and Sqlite3 from scratch?

回答1:

As the warning suggests, sqlite3-ruby requires native C extension, and it does not work well with JRuby.

You should use activerecord-jdbcsqlite3-adapter instead.

https://rubygems.org/gems/activerecord-jdbcsqlite3-adapter

See https://github.com/jruby/activerecord-jdbc-adapter